12874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 22d283bddSGavin Shan /* 32d283bddSGavin Shan * Copyright Gavin Shan, IBM Corporation 2016. 42d283bddSGavin Shan */ 52d283bddSGavin Shan 62d283bddSGavin Shan #ifndef __NCSI_INTERNAL_H__ 72d283bddSGavin Shan #define __NCSI_INTERNAL_H__ 82d283bddSGavin Shan 92d283bddSGavin Shan enum { 102d283bddSGavin Shan NCSI_CAP_BASE = 0, 112d283bddSGavin Shan NCSI_CAP_GENERIC = 0, 122d283bddSGavin Shan NCSI_CAP_BC, 132d283bddSGavin Shan NCSI_CAP_MC, 142d283bddSGavin Shan NCSI_CAP_BUFFER, 152d283bddSGavin Shan NCSI_CAP_AEN, 162d283bddSGavin Shan NCSI_CAP_VLAN, 172d283bddSGavin Shan NCSI_CAP_MAX 182d283bddSGavin Shan }; 192d283bddSGavin Shan 202d283bddSGavin Shan enum { 212d283bddSGavin Shan NCSI_CAP_GENERIC_HWA = 0x01, /* HW arbitration */ 222d283bddSGavin Shan NCSI_CAP_GENERIC_HDS = 0x02, /* HNC driver status change */ 232d283bddSGavin Shan NCSI_CAP_GENERIC_FC = 0x04, /* HNC to MC flow control */ 242d283bddSGavin Shan NCSI_CAP_GENERIC_FC1 = 0x08, /* MC to HNC flow control */ 252d283bddSGavin Shan NCSI_CAP_GENERIC_MC = 0x10, /* Global MC filtering */ 262d283bddSGavin Shan NCSI_CAP_GENERIC_HWA_UNKNOWN = 0x00, /* Unknown HW arbitration */ 272d283bddSGavin Shan NCSI_CAP_GENERIC_HWA_SUPPORT = 0x20, /* Supported HW arbitration */ 282d283bddSGavin Shan NCSI_CAP_GENERIC_HWA_NOT_SUPPORT = 0x40, /* No HW arbitration */ 292d283bddSGavin Shan NCSI_CAP_GENERIC_HWA_RESERVED = 0x60, /* Reserved HW arbitration */ 302d283bddSGavin Shan NCSI_CAP_GENERIC_HWA_MASK = 0x60, /* Mask for HW arbitration */ 312d283bddSGavin Shan NCSI_CAP_GENERIC_MASK = 0x7f, 322d283bddSGavin Shan NCSI_CAP_BC_ARP = 0x01, /* ARP packet filtering */ 332d283bddSGavin Shan NCSI_CAP_BC_DHCPC = 0x02, /* DHCP client filtering */ 342d283bddSGavin Shan NCSI_CAP_BC_DHCPS = 0x04, /* DHCP server filtering */ 352d283bddSGavin Shan NCSI_CAP_BC_NETBIOS = 0x08, /* NetBIOS packet filtering */ 362d283bddSGavin Shan NCSI_CAP_BC_MASK = 0x0f, 372d283bddSGavin Shan NCSI_CAP_MC_IPV6_NEIGHBOR = 0x01, /* IPv6 neighbor filtering */ 382d283bddSGavin Shan NCSI_CAP_MC_IPV6_ROUTER = 0x02, /* IPv6 router filering */ 392d283bddSGavin Shan NCSI_CAP_MC_DHCPV6_RELAY = 0x04, /* DHCPv6 relay / server MC */ 402d283bddSGavin Shan NCSI_CAP_MC_DHCPV6_WELL_KNOWN = 0x08, /* DHCPv6 well-known MC */ 412d283bddSGavin Shan NCSI_CAP_MC_IPV6_MLD = 0x10, /* IPv6 MLD filtering */ 422d283bddSGavin Shan NCSI_CAP_MC_IPV6_NEIGHBOR_S = 0x20, /* IPv6 neighbour filtering */ 432d283bddSGavin Shan NCSI_CAP_MC_MASK = 0x3f, 442d283bddSGavin Shan NCSI_CAP_AEN_LSC = 0x01, /* Link status change */ 452d283bddSGavin Shan NCSI_CAP_AEN_CR = 0x02, /* Configuration required */ 462d283bddSGavin Shan NCSI_CAP_AEN_HDS = 0x04, /* HNC driver status */ 472d283bddSGavin Shan NCSI_CAP_AEN_MASK = 0x07, 482d283bddSGavin Shan NCSI_CAP_VLAN_ONLY = 0x01, /* Filter VLAN packet only */ 492d283bddSGavin Shan NCSI_CAP_VLAN_NO = 0x02, /* Filter VLAN and non-VLAN */ 502d283bddSGavin Shan NCSI_CAP_VLAN_ANY = 0x04, /* Filter Any-and-non-VLAN */ 512d283bddSGavin Shan NCSI_CAP_VLAN_MASK = 0x07 522d283bddSGavin Shan }; 532d283bddSGavin Shan 542d283bddSGavin Shan enum { 552d283bddSGavin Shan NCSI_MODE_BASE = 0, 562d283bddSGavin Shan NCSI_MODE_ENABLE = 0, 572d283bddSGavin Shan NCSI_MODE_TX_ENABLE, 582d283bddSGavin Shan NCSI_MODE_LINK, 592d283bddSGavin Shan NCSI_MODE_VLAN, 602d283bddSGavin Shan NCSI_MODE_BC, 612d283bddSGavin Shan NCSI_MODE_MC, 622d283bddSGavin Shan NCSI_MODE_AEN, 632d283bddSGavin Shan NCSI_MODE_FC, 642d283bddSGavin Shan NCSI_MODE_MAX 652d283bddSGavin Shan }; 662d283bddSGavin Shan 675e0fcc16SVijay Khemka /* Supported media status bits for Mellanox Mac affinity command. 685e0fcc16SVijay Khemka * Bit (0-2) for different protocol support; Bit 1 for RBT support, 695e0fcc16SVijay Khemka * bit 1 for SMBUS support and bit 2 for PCIE support. Bit (3-5) 705e0fcc16SVijay Khemka * for different protocol availability. Bit 4 for RBT, bit 4 for 715e0fcc16SVijay Khemka * SMBUS and bit 5 for PCIE. 725e0fcc16SVijay Khemka */ 735e0fcc16SVijay Khemka enum { 745e0fcc16SVijay Khemka MLX_MC_RBT_SUPPORT = 0x01, /* MC supports RBT */ 755e0fcc16SVijay Khemka MLX_MC_RBT_AVL = 0x08, /* RBT medium is available */ 765e0fcc16SVijay Khemka }; 775e0fcc16SVijay Khemka 78fb4ee675SVijay Khemka /* OEM Vendor Manufacture ID */ 79fb4ee675SVijay Khemka #define NCSI_OEM_MFR_MLX_ID 0x8119 80fb4ee675SVijay Khemka #define NCSI_OEM_MFR_BCM_ID 0x113d 81abd2fddcSIvan Mikhaylov #define NCSI_OEM_MFR_INTEL_ID 0x157 82abd2fddcSIvan Mikhaylov /* Intel specific OEM command */ 83205b95feSIvan Mikhaylov #define NCSI_OEM_INTEL_CMD_GMA 0x06 /* CMD ID for Get MAC */ 84abd2fddcSIvan Mikhaylov #define NCSI_OEM_INTEL_CMD_KEEP_PHY 0x20 /* CMD ID for Keep PHY up */ 85cb10c7c0SVijay Khemka /* Broadcom specific OEM Command */ 86cb10c7c0SVijay Khemka #define NCSI_OEM_BCM_CMD_GMA 0x01 /* CMD ID for Get MAC */ 8716e8c4caSVijay Khemka /* Mellanox specific OEM Command */ 8816e8c4caSVijay Khemka #define NCSI_OEM_MLX_CMD_GMA 0x00 /* CMD ID for Get MAC */ 8916e8c4caSVijay Khemka #define NCSI_OEM_MLX_CMD_GMA_PARAM 0x1b /* Parameter for GMA */ 905e0fcc16SVijay Khemka #define NCSI_OEM_MLX_CMD_SMAF 0x01 /* CMD ID for Set MC Affinity */ 915e0fcc16SVijay Khemka #define NCSI_OEM_MLX_CMD_SMAF_PARAM 0x07 /* Parameter for SMAF */ 92cb10c7c0SVijay Khemka /* OEM Command payload lengths*/ 93205b95feSIvan Mikhaylov #define NCSI_OEM_INTEL_CMD_GMA_LEN 5 94abd2fddcSIvan Mikhaylov #define NCSI_OEM_INTEL_CMD_KEEP_PHY_LEN 7 95cb10c7c0SVijay Khemka #define NCSI_OEM_BCM_CMD_GMA_LEN 12 9616e8c4caSVijay Khemka #define NCSI_OEM_MLX_CMD_GMA_LEN 8 975e0fcc16SVijay Khemka #define NCSI_OEM_MLX_CMD_SMAF_LEN 60 985e0fcc16SVijay Khemka /* Offset in OEM request */ 995e0fcc16SVijay Khemka #define MLX_SMAF_MAC_ADDR_OFFSET 8 /* Offset for MAC in SMAF */ 1005e0fcc16SVijay Khemka #define MLX_SMAF_MED_SUPPORT_OFFSET 14 /* Offset for medium in SMAF */ 101cb10c7c0SVijay Khemka /* Mac address offset in OEM response */ 102cb10c7c0SVijay Khemka #define BCM_MAC_ADDR_OFFSET 28 10316e8c4caSVijay Khemka #define MLX_MAC_ADDR_OFFSET 8 104205b95feSIvan Mikhaylov #define INTEL_MAC_ADDR_OFFSET 1 105cb10c7c0SVijay Khemka 106fb4ee675SVijay Khemka 1072d283bddSGavin Shan struct ncsi_channel_version { 1081c83c708SPeter Delevoryas u8 major; /* NCSI version major */ 1091c83c708SPeter Delevoryas u8 minor; /* NCSI version minor */ 1101c83c708SPeter Delevoryas u8 update; /* NCSI version update */ 1111c83c708SPeter Delevoryas char alpha1; /* NCSI version alpha1 */ 1121c83c708SPeter Delevoryas char alpha2; /* NCSI version alpha2 */ 113195a8ec4SBhaskar Chowdhury u8 fw_name[12]; /* Firmware name string */ 1142d283bddSGavin Shan u32 fw_version; /* Firmware version */ 1152d283bddSGavin Shan u16 pci_ids[4]; /* PCI identification */ 1162d283bddSGavin Shan u32 mf_id; /* Manufacture ID */ 1172d283bddSGavin Shan }; 1182d283bddSGavin Shan 1192d283bddSGavin Shan struct ncsi_channel_cap { 1202d283bddSGavin Shan u32 index; /* Index of channel capabilities */ 1212d283bddSGavin Shan u32 cap; /* NCSI channel capability */ 1222d283bddSGavin Shan }; 1232d283bddSGavin Shan 1242d283bddSGavin Shan struct ncsi_channel_mode { 1252d283bddSGavin Shan u32 index; /* Index of channel modes */ 1262d283bddSGavin Shan u32 enable; /* Enabled or disabled */ 1272d283bddSGavin Shan u32 size; /* Valid entries in ncm_data[] */ 1282d283bddSGavin Shan u32 data[8]; /* Data entries */ 1292d283bddSGavin Shan }; 1302d283bddSGavin Shan 131062b3e1bSSamuel Mendoza-Jonas struct ncsi_channel_mac_filter { 132062b3e1bSSamuel Mendoza-Jonas u8 n_uc; 133062b3e1bSSamuel Mendoza-Jonas u8 n_mc; 134062b3e1bSSamuel Mendoza-Jonas u8 n_mixed; 135062b3e1bSSamuel Mendoza-Jonas u64 bitmap; 136062b3e1bSSamuel Mendoza-Jonas unsigned char *addrs; 137062b3e1bSSamuel Mendoza-Jonas }; 138062b3e1bSSamuel Mendoza-Jonas 139062b3e1bSSamuel Mendoza-Jonas struct ncsi_channel_vlan_filter { 140062b3e1bSSamuel Mendoza-Jonas u8 n_vids; 141062b3e1bSSamuel Mendoza-Jonas u64 bitmap; 142062b3e1bSSamuel Mendoza-Jonas u16 *vids; 1432d283bddSGavin Shan }; 1442d283bddSGavin Shan 1452d283bddSGavin Shan struct ncsi_channel_stats { 1462d283bddSGavin Shan u32 hnc_cnt_hi; /* Counter cleared */ 1472d283bddSGavin Shan u32 hnc_cnt_lo; /* Counter cleared */ 1482d283bddSGavin Shan u32 hnc_rx_bytes; /* Rx bytes */ 1492d283bddSGavin Shan u32 hnc_tx_bytes; /* Tx bytes */ 1502d283bddSGavin Shan u32 hnc_rx_uc_pkts; /* Rx UC packets */ 1512d283bddSGavin Shan u32 hnc_rx_mc_pkts; /* Rx MC packets */ 1522d283bddSGavin Shan u32 hnc_rx_bc_pkts; /* Rx BC packets */ 1532d283bddSGavin Shan u32 hnc_tx_uc_pkts; /* Tx UC packets */ 1542d283bddSGavin Shan u32 hnc_tx_mc_pkts; /* Tx MC packets */ 1552d283bddSGavin Shan u32 hnc_tx_bc_pkts; /* Tx BC packets */ 1562d283bddSGavin Shan u32 hnc_fcs_err; /* FCS errors */ 1572d283bddSGavin Shan u32 hnc_align_err; /* Alignment errors */ 1582d283bddSGavin Shan u32 hnc_false_carrier; /* False carrier detection */ 1592d283bddSGavin Shan u32 hnc_runt_pkts; /* Rx runt packets */ 1602d283bddSGavin Shan u32 hnc_jabber_pkts; /* Rx jabber packets */ 1612d283bddSGavin Shan u32 hnc_rx_pause_xon; /* Rx pause XON frames */ 1622d283bddSGavin Shan u32 hnc_rx_pause_xoff; /* Rx XOFF frames */ 1632d283bddSGavin Shan u32 hnc_tx_pause_xon; /* Tx XON frames */ 1642d283bddSGavin Shan u32 hnc_tx_pause_xoff; /* Tx XOFF frames */ 1652d283bddSGavin Shan u32 hnc_tx_s_collision; /* Single collision frames */ 1662d283bddSGavin Shan u32 hnc_tx_m_collision; /* Multiple collision frames */ 1672d283bddSGavin Shan u32 hnc_l_collision; /* Late collision frames */ 1682d283bddSGavin Shan u32 hnc_e_collision; /* Excessive collision frames */ 1692d283bddSGavin Shan u32 hnc_rx_ctl_frames; /* Rx control frames */ 1702d283bddSGavin Shan u32 hnc_rx_64_frames; /* Rx 64-bytes frames */ 1712d283bddSGavin Shan u32 hnc_rx_127_frames; /* Rx 65-127 bytes frames */ 1722d283bddSGavin Shan u32 hnc_rx_255_frames; /* Rx 128-255 bytes frames */ 1732d283bddSGavin Shan u32 hnc_rx_511_frames; /* Rx 256-511 bytes frames */ 1742d283bddSGavin Shan u32 hnc_rx_1023_frames; /* Rx 512-1023 bytes frames */ 1752d283bddSGavin Shan u32 hnc_rx_1522_frames; /* Rx 1024-1522 bytes frames */ 1762d283bddSGavin Shan u32 hnc_rx_9022_frames; /* Rx 1523-9022 bytes frames */ 1772d283bddSGavin Shan u32 hnc_tx_64_frames; /* Tx 64-bytes frames */ 1782d283bddSGavin Shan u32 hnc_tx_127_frames; /* Tx 65-127 bytes frames */ 1792d283bddSGavin Shan u32 hnc_tx_255_frames; /* Tx 128-255 bytes frames */ 1802d283bddSGavin Shan u32 hnc_tx_511_frames; /* Tx 256-511 bytes frames */ 1812d283bddSGavin Shan u32 hnc_tx_1023_frames; /* Tx 512-1023 bytes frames */ 1822d283bddSGavin Shan u32 hnc_tx_1522_frames; /* Tx 1024-1522 bytes frames */ 1832d283bddSGavin Shan u32 hnc_tx_9022_frames; /* Tx 1523-9022 bytes frames */ 1842d283bddSGavin Shan u32 hnc_rx_valid_bytes; /* Rx valid bytes */ 1852d283bddSGavin Shan u32 hnc_rx_runt_pkts; /* Rx error runt packets */ 1862d283bddSGavin Shan u32 hnc_rx_jabber_pkts; /* Rx error jabber packets */ 1872d283bddSGavin Shan u32 ncsi_rx_cmds; /* Rx NCSI commands */ 1882d283bddSGavin Shan u32 ncsi_dropped_cmds; /* Dropped commands */ 1892d283bddSGavin Shan u32 ncsi_cmd_type_errs; /* Command type errors */ 1902d283bddSGavin Shan u32 ncsi_cmd_csum_errs; /* Command checksum errors */ 1912d283bddSGavin Shan u32 ncsi_rx_pkts; /* Rx NCSI packets */ 1922d283bddSGavin Shan u32 ncsi_tx_pkts; /* Tx NCSI packets */ 1932d283bddSGavin Shan u32 ncsi_tx_aen_pkts; /* Tx AEN packets */ 1942d283bddSGavin Shan u32 pt_tx_pkts; /* Tx packets */ 1952d283bddSGavin Shan u32 pt_tx_dropped; /* Tx dropped packets */ 1962d283bddSGavin Shan u32 pt_tx_channel_err; /* Tx channel errors */ 1972d283bddSGavin Shan u32 pt_tx_us_err; /* Tx undersize errors */ 1982d283bddSGavin Shan u32 pt_rx_pkts; /* Rx packets */ 1992d283bddSGavin Shan u32 pt_rx_dropped; /* Rx dropped packets */ 2002d283bddSGavin Shan u32 pt_rx_channel_err; /* Rx channel errors */ 2012d283bddSGavin Shan u32 pt_rx_us_err; /* Rx undersize errors */ 2022d283bddSGavin Shan u32 pt_rx_os_err; /* Rx oversize errors */ 2032d283bddSGavin Shan }; 2042d283bddSGavin Shan 2052d283bddSGavin Shan struct ncsi_dev_priv; 2062d283bddSGavin Shan struct ncsi_package; 2072d283bddSGavin Shan 2082d283bddSGavin Shan #define NCSI_PACKAGE_SHIFT 5 2092d283bddSGavin Shan #define NCSI_PACKAGE_INDEX(c) (((c) >> NCSI_PACKAGE_SHIFT) & 0x7) 210bc7e0f50SGavin Shan #define NCSI_RESERVED_CHANNEL 0x1f 2112d283bddSGavin Shan #define NCSI_CHANNEL_INDEX(c) ((c) & ((1 << NCSI_PACKAGE_SHIFT) - 1)) 2122d283bddSGavin Shan #define NCSI_TO_CHANNEL(p, c) (((p) << NCSI_PACKAGE_SHIFT) | (c)) 2139771b8ccSJustin.Lee1@Dell.com #define NCSI_MAX_PACKAGE 8 2149771b8ccSJustin.Lee1@Dell.com #define NCSI_MAX_CHANNEL 32 2152d283bddSGavin Shan 2162d283bddSGavin Shan struct ncsi_channel { 2172d283bddSGavin Shan unsigned char id; 2182d283bddSGavin Shan int state; 2192d283bddSGavin Shan #define NCSI_CHANNEL_INACTIVE 1 2202d283bddSGavin Shan #define NCSI_CHANNEL_ACTIVE 2 221e6f44ed6SGavin Shan #define NCSI_CHANNEL_INVISIBLE 3 22221acf630SSamuel Mendoza-Jonas bool reconfigure_needed; 2232d283bddSGavin Shan spinlock_t lock; /* Protect filters etc */ 2242d283bddSGavin Shan struct ncsi_package *package; 2252d283bddSGavin Shan struct ncsi_channel_version version; 2262d283bddSGavin Shan struct ncsi_channel_cap caps[NCSI_CAP_MAX]; 2272d283bddSGavin Shan struct ncsi_channel_mode modes[NCSI_MODE_MAX]; 228062b3e1bSSamuel Mendoza-Jonas /* Filtering Settings */ 229062b3e1bSSamuel Mendoza-Jonas struct ncsi_channel_mac_filter mac_filter; 230062b3e1bSSamuel Mendoza-Jonas struct ncsi_channel_vlan_filter vlan_filter; 2312d283bddSGavin Shan struct ncsi_channel_stats stats; 23283afdc6aSGavin Shan struct { 23383afdc6aSGavin Shan struct timer_list timer; 23483afdc6aSGavin Shan bool enabled; 23583afdc6aSGavin Shan unsigned int state; 23683afdc6aSGavin Shan #define NCSI_CHANNEL_MONITOR_START 0 23783afdc6aSGavin Shan #define NCSI_CHANNEL_MONITOR_RETRY 1 23883afdc6aSGavin Shan #define NCSI_CHANNEL_MONITOR_WAIT 2 23983afdc6aSGavin Shan #define NCSI_CHANNEL_MONITOR_WAIT_MAX 5 24083afdc6aSGavin Shan } monitor; 2412d283bddSGavin Shan struct list_head node; 242e6f44ed6SGavin Shan struct list_head link; 2432d283bddSGavin Shan }; 2442d283bddSGavin Shan 2452d283bddSGavin Shan struct ncsi_package { 2462d283bddSGavin Shan unsigned char id; /* NCSI 3-bits package ID */ 2472d283bddSGavin Shan unsigned char uuid[16]; /* UUID */ 2482d283bddSGavin Shan struct ncsi_dev_priv *ndp; /* NCSI device */ 2492d283bddSGavin Shan spinlock_t lock; /* Protect the package */ 2502d283bddSGavin Shan unsigned int channel_num; /* Number of channels */ 2514fb3ebbfSZheng Yongjun struct list_head channels; /* List of channels */ 2522d283bddSGavin Shan struct list_head node; /* Form list of packages */ 2538d951a75SSamuel Mendoza-Jonas 2548d951a75SSamuel Mendoza-Jonas bool multi_channel; /* Enable multiple channels */ 2558d951a75SSamuel Mendoza-Jonas u32 channel_whitelist; /* Channels to configure */ 2568d951a75SSamuel Mendoza-Jonas struct ncsi_channel *preferred_channel; /* Primary channel */ 2572d283bddSGavin Shan }; 2582d283bddSGavin Shan 2592d283bddSGavin Shan struct ncsi_request { 2602d283bddSGavin Shan unsigned char id; /* Request ID - 0 to 255 */ 2612d283bddSGavin Shan bool used; /* Request that has been assigned */ 262a0509cbeSGavin Shan unsigned int flags; /* NCSI request property */ 263a0509cbeSGavin Shan #define NCSI_REQ_FLAG_EVENT_DRIVEN 1 2649771b8ccSJustin.Lee1@Dell.com #define NCSI_REQ_FLAG_NETLINK_DRIVEN 2 2652d283bddSGavin Shan struct ncsi_dev_priv *ndp; /* Associated NCSI device */ 2662d283bddSGavin Shan struct sk_buff *cmd; /* Associated NCSI command packet */ 2672d283bddSGavin Shan struct sk_buff *rsp; /* Associated NCSI response packet */ 2682d283bddSGavin Shan struct timer_list timer; /* Timer on waiting for response */ 2692d283bddSGavin Shan bool enabled; /* Time has been enabled or not */ 2709771b8ccSJustin.Lee1@Dell.com u32 snd_seq; /* netlink sending sequence number */ 2719771b8ccSJustin.Lee1@Dell.com u32 snd_portid; /* netlink portid of sender */ 2729771b8ccSJustin.Lee1@Dell.com struct nlmsghdr nlhdr; /* netlink message header */ 2732d283bddSGavin Shan }; 2742d283bddSGavin Shan 275e6f44ed6SGavin Shan enum { 276e6f44ed6SGavin Shan ncsi_dev_state_major = 0xff00, 277e6f44ed6SGavin Shan ncsi_dev_state_minor = 0x00ff, 278e6f44ed6SGavin Shan ncsi_dev_state_probe_deselect = 0x0201, 279e6f44ed6SGavin Shan ncsi_dev_state_probe_package, 280e6f44ed6SGavin Shan ncsi_dev_state_probe_channel, 2815e0fcc16SVijay Khemka ncsi_dev_state_probe_mlx_gma, 2825e0fcc16SVijay Khemka ncsi_dev_state_probe_mlx_smaf, 283e6f44ed6SGavin Shan ncsi_dev_state_probe_cis, 284abd2fddcSIvan Mikhaylov ncsi_dev_state_probe_keep_phy, 285e6f44ed6SGavin Shan ncsi_dev_state_probe_gvi, 286e6f44ed6SGavin Shan ncsi_dev_state_probe_gc, 287e6f44ed6SGavin Shan ncsi_dev_state_probe_gls, 288e6f44ed6SGavin Shan ncsi_dev_state_probe_dp, 289e6f44ed6SGavin Shan ncsi_dev_state_config_sp = 0x0301, 290e6f44ed6SGavin Shan ncsi_dev_state_config_cis, 291cb10c7c0SVijay Khemka ncsi_dev_state_config_oem_gma, 29221acf630SSamuel Mendoza-Jonas ncsi_dev_state_config_clear_vids, 29321acf630SSamuel Mendoza-Jonas ncsi_dev_state_config_svf, 29421acf630SSamuel Mendoza-Jonas ncsi_dev_state_config_ev, 295e6f44ed6SGavin Shan ncsi_dev_state_config_sma, 296e6f44ed6SGavin Shan ncsi_dev_state_config_ebf, 297cf0eba33SVijay Khemka ncsi_dev_state_config_dgmf, 298e6f44ed6SGavin Shan ncsi_dev_state_config_ecnt, 299e6f44ed6SGavin Shan ncsi_dev_state_config_ec, 300e6f44ed6SGavin Shan ncsi_dev_state_config_ae, 301e6f44ed6SGavin Shan ncsi_dev_state_config_gls, 302e6f44ed6SGavin Shan ncsi_dev_state_config_done, 303e6f44ed6SGavin Shan ncsi_dev_state_suspend_select = 0x0401, 304008a424aSGavin Shan ncsi_dev_state_suspend_gls, 305e6f44ed6SGavin Shan ncsi_dev_state_suspend_dcnt, 306e6f44ed6SGavin Shan ncsi_dev_state_suspend_dc, 307e6f44ed6SGavin Shan ncsi_dev_state_suspend_deselect, 308e6f44ed6SGavin Shan ncsi_dev_state_suspend_done 309e6f44ed6SGavin Shan }; 310e6f44ed6SGavin Shan 31121acf630SSamuel Mendoza-Jonas struct vlan_vid { 31221acf630SSamuel Mendoza-Jonas struct list_head list; 31321acf630SSamuel Mendoza-Jonas __be16 proto; 31421acf630SSamuel Mendoza-Jonas u16 vid; 31521acf630SSamuel Mendoza-Jonas }; 31621acf630SSamuel Mendoza-Jonas 3172d283bddSGavin Shan struct ncsi_dev_priv { 3182d283bddSGavin Shan struct ncsi_dev ndev; /* Associated NCSI device */ 3192d283bddSGavin Shan unsigned int flags; /* NCSI device flags */ 320e6f44ed6SGavin Shan #define NCSI_DEV_PROBED 1 /* Finalized NCSI topology */ 321e6f44ed6SGavin Shan #define NCSI_DEV_HWA 2 /* Enabled HW arbitration */ 322e6f44ed6SGavin Shan #define NCSI_DEV_RESHUFFLE 4 3232878a2cfSSamuel Mendoza-Jonas #define NCSI_DEV_RESET 8 /* Reset state of NC */ 324cb10c7c0SVijay Khemka unsigned int gma_flag; /* OEM GMA flag */ 3252d283bddSGavin Shan spinlock_t lock; /* Protect the NCSI device */ 3268e13f70bSSamuel Mendoza-Jonas unsigned int package_probe_id;/* Current ID during probe */ 3272d283bddSGavin Shan unsigned int package_num; /* Number of packages */ 328*645e643eSDelphineCCChiu unsigned int channel_probe_id;/* Current cahnnel ID during probe */ 3292d283bddSGavin Shan struct list_head packages; /* List of packages */ 330bbc7c01eSGavin Shan struct ncsi_channel *hot_channel; /* Channel was ever active */ 3312d283bddSGavin Shan struct ncsi_request requests[256]; /* Request table */ 3322d283bddSGavin Shan unsigned int request_id; /* Last used request ID */ 333a15af54fSGavin Shan #define NCSI_REQ_START_IDX 1 334e6f44ed6SGavin Shan unsigned int pending_req_num; /* Number of pending requests */ 335e6f44ed6SGavin Shan struct ncsi_package *active_package; /* Currently handled package */ 336e6f44ed6SGavin Shan struct ncsi_channel *active_channel; /* Currently handled channel */ 337e6f44ed6SGavin Shan struct list_head channel_queue; /* Config queue of channels */ 338e6f44ed6SGavin Shan struct work_struct work; /* For channel management */ 339e6f44ed6SGavin Shan struct packet_type ptype; /* NCSI packet Rx handler */ 3402d283bddSGavin Shan struct list_head node; /* Form NCSI device list */ 3416e9c0075SSamuel Mendoza-Jonas #define NCSI_MAX_VLAN_VIDS 15 34221acf630SSamuel Mendoza-Jonas struct list_head vlan_vids; /* List of active VLAN IDs */ 3438d951a75SSamuel Mendoza-Jonas 3448d951a75SSamuel Mendoza-Jonas bool multi_package; /* Enable multiple packages */ 3455e0fcc16SVijay Khemka bool mlx_multi_host; /* Enable multi host Mellanox */ 3468d951a75SSamuel Mendoza-Jonas u32 package_whitelist; /* Packages to configure */ 347*645e643eSDelphineCCChiu unsigned char channel_count; /* Num of channels to probe */ 3482d283bddSGavin Shan }; 3492d283bddSGavin Shan 3506389eaa7SGavin Shan struct ncsi_cmd_arg { 3516389eaa7SGavin Shan struct ncsi_dev_priv *ndp; /* Associated NCSI device */ 3526389eaa7SGavin Shan unsigned char type; /* Command in the NCSI packet */ 3536389eaa7SGavin Shan unsigned char id; /* Request ID (sequence number) */ 3546389eaa7SGavin Shan unsigned char package; /* Destination package ID */ 3554fb3ebbfSZheng Yongjun unsigned char channel; /* Destination channel ID or 0x1f */ 3566389eaa7SGavin Shan unsigned short payload; /* Command packet payload length */ 357a0509cbeSGavin Shan unsigned int req_flags; /* NCSI request properties */ 3586389eaa7SGavin Shan union { 3596389eaa7SGavin Shan unsigned char bytes[16]; /* Command packet specific data */ 3606389eaa7SGavin Shan unsigned short words[8]; 3616389eaa7SGavin Shan unsigned int dwords[4]; 3626389eaa7SGavin Shan }; 363fb4ee675SVijay Khemka unsigned char *data; /* NCSI OEM data */ 3649771b8ccSJustin.Lee1@Dell.com struct genl_info *info; /* Netlink information */ 3656389eaa7SGavin Shan }; 3666389eaa7SGavin Shan 3672d283bddSGavin Shan extern struct list_head ncsi_dev_list; 3682d283bddSGavin Shan extern spinlock_t ncsi_dev_lock; 3692d283bddSGavin Shan 3702d283bddSGavin Shan #define TO_NCSI_DEV_PRIV(nd) \ 3712d283bddSGavin Shan container_of(nd, struct ncsi_dev_priv, ndev) 3722d283bddSGavin Shan #define NCSI_FOR_EACH_DEV(ndp) \ 3732d283bddSGavin Shan list_for_each_entry_rcu(ndp, &ncsi_dev_list, node) 3742d283bddSGavin Shan #define NCSI_FOR_EACH_PACKAGE(ndp, np) \ 3752d283bddSGavin Shan list_for_each_entry_rcu(np, &ndp->packages, node) 3762d283bddSGavin Shan #define NCSI_FOR_EACH_CHANNEL(np, nc) \ 3772d283bddSGavin Shan list_for_each_entry_rcu(nc, &np->channels, node) 3782d283bddSGavin Shan 3792d283bddSGavin Shan /* Resources */ 3802878a2cfSSamuel Mendoza-Jonas int ncsi_reset_dev(struct ncsi_dev *nd); 381e6f44ed6SGavin Shan void ncsi_start_channel_monitor(struct ncsi_channel *nc); 382e6f44ed6SGavin Shan void ncsi_stop_channel_monitor(struct ncsi_channel *nc); 3832d283bddSGavin Shan struct ncsi_channel *ncsi_find_channel(struct ncsi_package *np, 3842d283bddSGavin Shan unsigned char id); 3852d283bddSGavin Shan struct ncsi_channel *ncsi_add_channel(struct ncsi_package *np, 3862d283bddSGavin Shan unsigned char id); 3872d283bddSGavin Shan struct ncsi_package *ncsi_find_package(struct ncsi_dev_priv *ndp, 3882d283bddSGavin Shan unsigned char id); 3892d283bddSGavin Shan struct ncsi_package *ncsi_add_package(struct ncsi_dev_priv *ndp, 3902d283bddSGavin Shan unsigned char id); 3912d283bddSGavin Shan void ncsi_remove_package(struct ncsi_package *np); 3922d283bddSGavin Shan void ncsi_find_package_and_channel(struct ncsi_dev_priv *ndp, 3932d283bddSGavin Shan unsigned char id, 3942d283bddSGavin Shan struct ncsi_package **np, 3952d283bddSGavin Shan struct ncsi_channel **nc); 396a0509cbeSGavin Shan struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp, 397a0509cbeSGavin Shan unsigned int req_flags); 3982d283bddSGavin Shan void ncsi_free_request(struct ncsi_request *nr); 3992d283bddSGavin Shan struct ncsi_dev *ncsi_find_dev(struct net_device *dev); 400e6f44ed6SGavin Shan int ncsi_process_next_channel(struct ncsi_dev_priv *ndp); 4018d951a75SSamuel Mendoza-Jonas bool ncsi_channel_has_link(struct ncsi_channel *channel); 4028d951a75SSamuel Mendoza-Jonas bool ncsi_channel_is_last(struct ncsi_dev_priv *ndp, 4038d951a75SSamuel Mendoza-Jonas struct ncsi_channel *channel); 4048d951a75SSamuel Mendoza-Jonas int ncsi_update_tx_channel(struct ncsi_dev_priv *ndp, 4058d951a75SSamuel Mendoza-Jonas struct ncsi_package *np, 4068d951a75SSamuel Mendoza-Jonas struct ncsi_channel *disable, 4078d951a75SSamuel Mendoza-Jonas struct ncsi_channel *enable); 4082d283bddSGavin Shan 4096389eaa7SGavin Shan /* Packet handlers */ 4106389eaa7SGavin Shan u32 ncsi_calculate_checksum(unsigned char *data, int len); 4116389eaa7SGavin Shan int ncsi_xmit_cmd(struct ncsi_cmd_arg *nca); 412138635ccSGavin Shan int ncsi_rcv_rsp(struct sk_buff *skb, struct net_device *dev, 413138635ccSGavin Shan struct packet_type *pt, struct net_device *orig_dev); 4147a82ecf4SGavin Shan int ncsi_aen_handler(struct ncsi_dev_priv *ndp, struct sk_buff *skb); 4156389eaa7SGavin Shan 4162d283bddSGavin Shan #endif /* __NCSI_INTERNAL_H__ */ 417