Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/ncsi: Simplify Kconfig/dts control flow

Background:

1. CONFIG_NCSI_OEM_CMD_KEEP_PHY

If this is enabled, we send an extra OEM Intel command in the probe
sequence immediately after discovering a channel (e.g. after "Clear
Initial State").

2. CONFIG_NCSI_OEM_CMD_GET_MAC

If this is enabled, we send one of 3 OEM "Get MAC Address" commands from
Broadcom, Mellanox (Nvidida), and Intel in the *configuration* sequence
for a channel.

3. mellanox,multi-host (or mlx,multi-host)

Introduced by this patch:

https://lore.kernel.org/all/20200108234341.2590674-1-vijaykhemka@fb.com/

Which was actually originally from cosmo.chou@quantatw.com:

https://github.com/facebook/openbmc-linux/commit/9f132a10ec48db84613519258cd8a317fb9c8f1b

Cosmo claimed that the Nvidia ConnectX-4 and ConnectX-6 NIC's don't
respond to Get Version ID, et. al in the probe sequence unless you send
the Set MC Affinity command first.

Problem Statement:

We've been using a combination of #ifdef code blocks and IS_ENABLED()
conditions to conditionally send these OEM commands.

It makes adding any new code around these commands hard to understand.

Solution:

In this patch, I just want to remove the conditionally compiled blocks
of code, and always use IS_ENABLED(...) to do dynamic control flow.

I don't think the small amount of code this adds to non-users of the OEM
Kconfigs is a big deal.

Signed-off-by: Peter Delevoryas <peter@pjd.dev>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Peter Delevoryas and committed by
David S. Miller
c797ce16 f9672265

+3 -17
+3 -17
net/ncsi/ncsi-manage.c
··· 689 689 return 0; 690 690 } 691 691 692 - #if IS_ENABLED(CONFIG_NCSI_OEM_CMD_KEEP_PHY) 693 - 694 692 static int ncsi_oem_keep_phy_intel(struct ncsi_cmd_arg *nca) 695 693 { 696 694 unsigned char data[NCSI_OEM_INTEL_CMD_KEEP_PHY_LEN]; ··· 713 715 nca->type); 714 716 return ret; 715 717 } 716 - 717 - #endif 718 - 719 - #if IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC) 720 718 721 719 /* NCSI OEM Command APIs */ 722 720 static int ncsi_oem_gma_handler_bcm(struct ncsi_cmd_arg *nca) ··· 849 855 /* Get Mac address from NCSI device */ 850 856 return nch->handler(nca); 851 857 } 852 - 853 - #endif /* CONFIG_NCSI_OEM_CMD_GET_MAC */ 854 858 855 859 /* Determine if a given channel from the channel_queue should be used for Tx */ 856 860 static bool ncsi_channel_is_tx(struct ncsi_dev_priv *ndp, ··· 1031 1039 goto error; 1032 1040 } 1033 1041 1034 - nd->state = ncsi_dev_state_config_oem_gma; 1042 + nd->state = IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC) 1043 + ? ncsi_dev_state_config_oem_gma 1044 + : ncsi_dev_state_config_clear_vids; 1035 1045 break; 1036 1046 case ncsi_dev_state_config_oem_gma: 1037 1047 nd->state = ncsi_dev_state_config_clear_vids; 1038 - ret = -1; 1039 1048 1040 - #if IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC) 1041 1049 nca.type = NCSI_PKT_CMD_OEM; 1042 1050 nca.package = np->id; 1043 1051 nca.channel = nc->id; 1044 1052 ndp->pending_req_num = 1; 1045 1053 ret = ncsi_gma_handler(&nca, nc->version.mf_id); 1046 - #endif /* CONFIG_NCSI_OEM_CMD_GET_MAC */ 1047 - 1048 1054 if (ret < 0) 1049 1055 schedule_work(&ndp->work); 1050 1056 ··· 1394 1404 1395 1405 schedule_work(&ndp->work); 1396 1406 break; 1397 - #if IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC) 1398 1407 case ncsi_dev_state_probe_mlx_gma: 1399 1408 ndp->pending_req_num = 1; 1400 1409 ··· 1418 1429 1419 1430 nd->state = ncsi_dev_state_probe_cis; 1420 1431 break; 1421 - #endif /* CONFIG_NCSI_OEM_CMD_GET_MAC */ 1422 1432 case ncsi_dev_state_probe_cis: 1423 1433 ndp->pending_req_num = NCSI_RESERVED_CHANNEL; 1424 1434 ··· 1435 1447 if (IS_ENABLED(CONFIG_NCSI_OEM_CMD_KEEP_PHY)) 1436 1448 nd->state = ncsi_dev_state_probe_keep_phy; 1437 1449 break; 1438 - #if IS_ENABLED(CONFIG_NCSI_OEM_CMD_KEEP_PHY) 1439 1450 case ncsi_dev_state_probe_keep_phy: 1440 1451 ndp->pending_req_num = 1; 1441 1452 ··· 1447 1460 1448 1461 nd->state = ncsi_dev_state_probe_gvi; 1449 1462 break; 1450 - #endif /* CONFIG_NCSI_OEM_CMD_KEEP_PHY */ 1451 1463 case ncsi_dev_state_probe_gvi: 1452 1464 case ncsi_dev_state_probe_gc: 1453 1465 case ncsi_dev_state_probe_gls: