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

net/ncsi: Support for multi host mellanox card

Multi host Mellanox cards require MAC affinity to be set
before receiving any config commands. All config commands
should also have unicast address for source address in
command header.

Adding GMA and SMAF(Set Mac Affinity) for Mellanox card
and call these in channel probe state machine if it is
defined in device tree.

Signed-off-by: Vijay Khemka <vijaykhemka@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vijay Khemka and committed by
David S. Miller
5e0fcc16 2cab57e0

+89
+20
net/ncsi/internal.h
··· 64 64 NCSI_MODE_MAX 65 65 }; 66 66 67 + /* Supported media status bits for Mellanox Mac affinity command. 68 + * Bit (0-2) for different protocol support; Bit 1 for RBT support, 69 + * bit 1 for SMBUS support and bit 2 for PCIE support. Bit (3-5) 70 + * for different protocol availability. Bit 4 for RBT, bit 4 for 71 + * SMBUS and bit 5 for PCIE. 72 + */ 73 + enum { 74 + MLX_MC_RBT_SUPPORT = 0x01, /* MC supports RBT */ 75 + MLX_MC_RBT_AVL = 0x08, /* RBT medium is available */ 76 + }; 77 + 67 78 /* OEM Vendor Manufacture ID */ 68 79 #define NCSI_OEM_MFR_MLX_ID 0x8119 69 80 #define NCSI_OEM_MFR_BCM_ID 0x113d ··· 83 72 /* Mellanox specific OEM Command */ 84 73 #define NCSI_OEM_MLX_CMD_GMA 0x00 /* CMD ID for Get MAC */ 85 74 #define NCSI_OEM_MLX_CMD_GMA_PARAM 0x1b /* Parameter for GMA */ 75 + #define NCSI_OEM_MLX_CMD_SMAF 0x01 /* CMD ID for Set MC Affinity */ 76 + #define NCSI_OEM_MLX_CMD_SMAF_PARAM 0x07 /* Parameter for SMAF */ 86 77 /* OEM Command payload lengths*/ 87 78 #define NCSI_OEM_BCM_CMD_GMA_LEN 12 88 79 #define NCSI_OEM_MLX_CMD_GMA_LEN 8 80 + #define NCSI_OEM_MLX_CMD_SMAF_LEN 60 81 + /* Offset in OEM request */ 82 + #define MLX_SMAF_MAC_ADDR_OFFSET 8 /* Offset for MAC in SMAF */ 83 + #define MLX_SMAF_MED_SUPPORT_OFFSET 14 /* Offset for medium in SMAF */ 89 84 /* Mac address offset in OEM response */ 90 85 #define BCM_MAC_ADDR_OFFSET 28 91 86 #define MLX_MAC_ADDR_OFFSET 8 ··· 268 251 ncsi_dev_state_probe_deselect = 0x0201, 269 252 ncsi_dev_state_probe_package, 270 253 ncsi_dev_state_probe_channel, 254 + ncsi_dev_state_probe_mlx_gma, 255 + ncsi_dev_state_probe_mlx_smaf, 271 256 ncsi_dev_state_probe_cis, 272 257 ncsi_dev_state_probe_gvi, 273 258 ncsi_dev_state_probe_gc, ··· 330 311 struct list_head vlan_vids; /* List of active VLAN IDs */ 331 312 332 313 bool multi_package; /* Enable multiple packages */ 314 + bool mlx_multi_host; /* Enable multi host Mellanox */ 333 315 u32 package_whitelist; /* Packages to configure */ 334 316 }; 335 317
+69
net/ncsi/ncsi-manage.c
··· 8 8 #include <linux/init.h> 9 9 #include <linux/netdevice.h> 10 10 #include <linux/skbuff.h> 11 + #include <linux/of.h> 12 + #include <linux/platform_device.h> 11 13 12 14 #include <net/ncsi.h> 13 15 #include <net/net_namespace.h> ··· 732 730 return ret; 733 731 } 734 732 733 + static int ncsi_oem_smaf_mlx(struct ncsi_cmd_arg *nca) 734 + { 735 + union { 736 + u8 data_u8[NCSI_OEM_MLX_CMD_SMAF_LEN]; 737 + u32 data_u32[NCSI_OEM_MLX_CMD_SMAF_LEN / sizeof(u32)]; 738 + } u; 739 + int ret = 0; 740 + 741 + memset(&u, 0, sizeof(u)); 742 + u.data_u32[0] = ntohl(NCSI_OEM_MFR_MLX_ID); 743 + u.data_u8[5] = NCSI_OEM_MLX_CMD_SMAF; 744 + u.data_u8[6] = NCSI_OEM_MLX_CMD_SMAF_PARAM; 745 + memcpy(&u.data_u8[MLX_SMAF_MAC_ADDR_OFFSET], 746 + nca->ndp->ndev.dev->dev_addr, ETH_ALEN); 747 + u.data_u8[MLX_SMAF_MED_SUPPORT_OFFSET] = 748 + (MLX_MC_RBT_AVL | MLX_MC_RBT_SUPPORT); 749 + 750 + nca->payload = NCSI_OEM_MLX_CMD_SMAF_LEN; 751 + nca->data = u.data_u8; 752 + 753 + ret = ncsi_xmit_cmd(nca); 754 + if (ret) 755 + netdev_err(nca->ndp->ndev.dev, 756 + "NCSI: Failed to transmit cmd 0x%x during probe\n", 757 + nca->type); 758 + return ret; 759 + } 760 + 735 761 /* OEM Command handlers initialization */ 736 762 static struct ncsi_oem_gma_handler { 737 763 unsigned int mfr_id; ··· 1340 1310 break; 1341 1311 } 1342 1312 nd->state = ncsi_dev_state_probe_cis; 1313 + if (IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC) && 1314 + ndp->mlx_multi_host) 1315 + nd->state = ncsi_dev_state_probe_mlx_gma; 1316 + 1343 1317 schedule_work(&ndp->work); 1344 1318 break; 1319 + #if IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC) 1320 + case ncsi_dev_state_probe_mlx_gma: 1321 + ndp->pending_req_num = 1; 1322 + 1323 + nca.type = NCSI_PKT_CMD_OEM; 1324 + nca.package = ndp->active_package->id; 1325 + nca.channel = 0; 1326 + ret = ncsi_oem_gma_handler_mlx(&nca); 1327 + if (ret) 1328 + goto error; 1329 + 1330 + nd->state = ncsi_dev_state_probe_mlx_smaf; 1331 + break; 1332 + case ncsi_dev_state_probe_mlx_smaf: 1333 + ndp->pending_req_num = 1; 1334 + 1335 + nca.type = NCSI_PKT_CMD_OEM; 1336 + nca.package = ndp->active_package->id; 1337 + nca.channel = 0; 1338 + ret = ncsi_oem_smaf_mlx(&nca); 1339 + if (ret) 1340 + goto error; 1341 + 1342 + nd->state = ncsi_dev_state_probe_cis; 1343 + break; 1344 + #endif /* CONFIG_NCSI_OEM_CMD_GET_MAC */ 1345 1345 case ncsi_dev_state_probe_cis: 1346 1346 ndp->pending_req_num = NCSI_RESERVED_CHANNEL; 1347 1347 ··· 1681 1621 { 1682 1622 struct ncsi_dev_priv *ndp; 1683 1623 struct ncsi_dev *nd; 1624 + struct platform_device *pdev; 1625 + struct device_node *np; 1684 1626 unsigned long flags; 1685 1627 int i; 1686 1628 ··· 1728 1666 1729 1667 /* Set up generic netlink interface */ 1730 1668 ncsi_init_netlink(dev); 1669 + 1670 + pdev = to_platform_device(dev->dev.parent); 1671 + if (pdev) { 1672 + np = pdev->dev.of_node; 1673 + if (np && of_get_property(np, "mlx,multi-host", NULL)) 1674 + ndp->mlx_multi_host = true; 1675 + } 1731 1676 1732 1677 return nd; 1733 1678 }