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 81cb10c7c0SVijay Khemka /* Broadcom specific OEM Command */ 82cb10c7c0SVijay Khemka #define NCSI_OEM_BCM_CMD_GMA 0x01 /* CMD ID for Get MAC */ 8316e8c4caSVijay Khemka /* Mellanox specific OEM Command */ 8416e8c4caSVijay Khemka #define NCSI_OEM_MLX_CMD_GMA 0x00 /* CMD ID for Get MAC */ 8516e8c4caSVijay Khemka #define NCSI_OEM_MLX_CMD_GMA_PARAM 0x1b /* Parameter for GMA */ 865e0fcc16SVijay Khemka #define NCSI_OEM_MLX_CMD_SMAF 0x01 /* CMD ID for Set MC Affinity */ 875e0fcc16SVijay Khemka #define NCSI_OEM_MLX_CMD_SMAF_PARAM 0x07 /* Parameter for SMAF */ 88cb10c7c0SVijay Khemka /* OEM Command payload lengths*/ 89cb10c7c0SVijay Khemka #define NCSI_OEM_BCM_CMD_GMA_LEN 12 9016e8c4caSVijay Khemka #define NCSI_OEM_MLX_CMD_GMA_LEN 8 915e0fcc16SVijay Khemka #define NCSI_OEM_MLX_CMD_SMAF_LEN 60 925e0fcc16SVijay Khemka /* Offset in OEM request */ 935e0fcc16SVijay Khemka #define MLX_SMAF_MAC_ADDR_OFFSET 8 /* Offset for MAC in SMAF */ 945e0fcc16SVijay Khemka #define MLX_SMAF_MED_SUPPORT_OFFSET 14 /* Offset for medium in SMAF */ 95cb10c7c0SVijay Khemka /* Mac address offset in OEM response */ 96cb10c7c0SVijay Khemka #define BCM_MAC_ADDR_OFFSET 28 9716e8c4caSVijay Khemka #define MLX_MAC_ADDR_OFFSET 8 98cb10c7c0SVijay Khemka 99fb4ee675SVijay Khemka 1002d283bddSGavin Shan struct ncsi_channel_version { 1012d283bddSGavin Shan u32 version; /* Supported BCD encoded NCSI version */ 1022d283bddSGavin Shan u32 alpha2; /* Supported BCD encoded NCSI version */ 103195a8ec4SBhaskar Chowdhury u8 fw_name[12]; /* Firmware name string */ 1042d283bddSGavin Shan u32 fw_version; /* Firmware version */ 1052d283bddSGavin Shan u16 pci_ids[4]; /* PCI identification */ 1062d283bddSGavin Shan u32 mf_id; /* Manufacture ID */ 1072d283bddSGavin Shan }; 1082d283bddSGavin Shan 1092d283bddSGavin Shan struct ncsi_channel_cap { 1102d283bddSGavin Shan u32 index; /* Index of channel capabilities */ 1112d283bddSGavin Shan u32 cap; /* NCSI channel capability */ 1122d283bddSGavin Shan }; 1132d283bddSGavin Shan 1142d283bddSGavin Shan struct ncsi_channel_mode { 1152d283bddSGavin Shan u32 index; /* Index of channel modes */ 1162d283bddSGavin Shan u32 enable; /* Enabled or disabled */ 1172d283bddSGavin Shan u32 size; /* Valid entries in ncm_data[] */ 1182d283bddSGavin Shan u32 data[8]; /* Data entries */ 1192d283bddSGavin Shan }; 1202d283bddSGavin Shan 121062b3e1bSSamuel Mendoza-Jonas struct ncsi_channel_mac_filter { 122062b3e1bSSamuel Mendoza-Jonas u8 n_uc; 123062b3e1bSSamuel Mendoza-Jonas u8 n_mc; 124062b3e1bSSamuel Mendoza-Jonas u8 n_mixed; 125062b3e1bSSamuel Mendoza-Jonas u64 bitmap; 126062b3e1bSSamuel Mendoza-Jonas unsigned char *addrs; 127062b3e1bSSamuel Mendoza-Jonas }; 128062b3e1bSSamuel Mendoza-Jonas 129062b3e1bSSamuel Mendoza-Jonas struct ncsi_channel_vlan_filter { 130062b3e1bSSamuel Mendoza-Jonas u8 n_vids; 131062b3e1bSSamuel Mendoza-Jonas u64 bitmap; 132062b3e1bSSamuel Mendoza-Jonas u16 *vids; 1332d283bddSGavin Shan }; 1342d283bddSGavin Shan 1352d283bddSGavin Shan struct ncsi_channel_stats { 1362d283bddSGavin Shan u32 hnc_cnt_hi; /* Counter cleared */ 1372d283bddSGavin Shan u32 hnc_cnt_lo; /* Counter cleared */ 1382d283bddSGavin Shan u32 hnc_rx_bytes; /* Rx bytes */ 1392d283bddSGavin Shan u32 hnc_tx_bytes; /* Tx bytes */ 1402d283bddSGavin Shan u32 hnc_rx_uc_pkts; /* Rx UC packets */ 1412d283bddSGavin Shan u32 hnc_rx_mc_pkts; /* Rx MC packets */ 1422d283bddSGavin Shan u32 hnc_rx_bc_pkts; /* Rx BC packets */ 1432d283bddSGavin Shan u32 hnc_tx_uc_pkts; /* Tx UC packets */ 1442d283bddSGavin Shan u32 hnc_tx_mc_pkts; /* Tx MC packets */ 1452d283bddSGavin Shan u32 hnc_tx_bc_pkts; /* Tx BC packets */ 1462d283bddSGavin Shan u32 hnc_fcs_err; /* FCS errors */ 1472d283bddSGavin Shan u32 hnc_align_err; /* Alignment errors */ 1482d283bddSGavin Shan u32 hnc_false_carrier; /* False carrier detection */ 1492d283bddSGavin Shan u32 hnc_runt_pkts; /* Rx runt packets */ 1502d283bddSGavin Shan u32 hnc_jabber_pkts; /* Rx jabber packets */ 1512d283bddSGavin Shan u32 hnc_rx_pause_xon; /* Rx pause XON frames */ 1522d283bddSGavin Shan u32 hnc_rx_pause_xoff; /* Rx XOFF frames */ 1532d283bddSGavin Shan u32 hnc_tx_pause_xon; /* Tx XON frames */ 1542d283bddSGavin Shan u32 hnc_tx_pause_xoff; /* Tx XOFF frames */ 1552d283bddSGavin Shan u32 hnc_tx_s_collision; /* Single collision frames */ 1562d283bddSGavin Shan u32 hnc_tx_m_collision; /* Multiple collision frames */ 1572d283bddSGavin Shan u32 hnc_l_collision; /* Late collision frames */ 1582d283bddSGavin Shan u32 hnc_e_collision; /* Excessive collision frames */ 1592d283bddSGavin Shan u32 hnc_rx_ctl_frames; /* Rx control frames */ 1602d283bddSGavin Shan u32 hnc_rx_64_frames; /* Rx 64-bytes frames */ 1612d283bddSGavin Shan u32 hnc_rx_127_frames; /* Rx 65-127 bytes frames */ 1622d283bddSGavin Shan u32 hnc_rx_255_frames; /* Rx 128-255 bytes frames */ 1632d283bddSGavin Shan u32 hnc_rx_511_frames; /* Rx 256-511 bytes frames */ 1642d283bddSGavin Shan u32 hnc_rx_1023_frames; /* Rx 512-1023 bytes frames */ 1652d283bddSGavin Shan u32 hnc_rx_1522_frames; /* Rx 1024-1522 bytes frames */ 1662d283bddSGavin Shan u32 hnc_rx_9022_frames; /* Rx 1523-9022 bytes frames */ 1672d283bddSGavin Shan u32 hnc_tx_64_frames; /* Tx 64-bytes frames */ 1682d283bddSGavin Shan u32 hnc_tx_127_frames; /* Tx 65-127 bytes frames */ 1692d283bddSGavin Shan u32 hnc_tx_255_frames; /* Tx 128-255 bytes frames */ 1702d283bddSGavin Shan u32 hnc_tx_511_frames; /* Tx 256-511 bytes frames */ 1712d283bddSGavin Shan u32 hnc_tx_1023_frames; /* Tx 512-1023 bytes frames */ 1722d283bddSGavin Shan u32 hnc_tx_1522_frames; /* Tx 1024-1522 bytes frames */ 1732d283bddSGavin Shan u32 hnc_tx_9022_frames; /* Tx 1523-9022 bytes frames */ 1742d283bddSGavin Shan u32 hnc_rx_valid_bytes; /* Rx valid bytes */ 1752d283bddSGavin Shan u32 hnc_rx_runt_pkts; /* Rx error runt packets */ 1762d283bddSGavin Shan u32 hnc_rx_jabber_pkts; /* Rx error jabber packets */ 1772d283bddSGavin Shan u32 ncsi_rx_cmds; /* Rx NCSI commands */ 1782d283bddSGavin Shan u32 ncsi_dropped_cmds; /* Dropped commands */ 1792d283bddSGavin Shan u32 ncsi_cmd_type_errs; /* Command type errors */ 1802d283bddSGavin Shan u32 ncsi_cmd_csum_errs; /* Command checksum errors */ 1812d283bddSGavin Shan u32 ncsi_rx_pkts; /* Rx NCSI packets */ 1822d283bddSGavin Shan u32 ncsi_tx_pkts; /* Tx NCSI packets */ 1832d283bddSGavin Shan u32 ncsi_tx_aen_pkts; /* Tx AEN packets */ 1842d283bddSGavin Shan u32 pt_tx_pkts; /* Tx packets */ 1852d283bddSGavin Shan u32 pt_tx_dropped; /* Tx dropped packets */ 1862d283bddSGavin Shan u32 pt_tx_channel_err; /* Tx channel errors */ 1872d283bddSGavin Shan u32 pt_tx_us_err; /* Tx undersize errors */ 1882d283bddSGavin Shan u32 pt_rx_pkts; /* Rx packets */ 1892d283bddSGavin Shan u32 pt_rx_dropped; /* Rx dropped packets */ 1902d283bddSGavin Shan u32 pt_rx_channel_err; /* Rx channel errors */ 1912d283bddSGavin Shan u32 pt_rx_us_err; /* Rx undersize errors */ 1922d283bddSGavin Shan u32 pt_rx_os_err; /* Rx oversize errors */ 1932d283bddSGavin Shan }; 1942d283bddSGavin Shan 1952d283bddSGavin Shan struct ncsi_dev_priv; 1962d283bddSGavin Shan struct ncsi_package; 1972d283bddSGavin Shan 1982d283bddSGavin Shan #define NCSI_PACKAGE_SHIFT 5 1992d283bddSGavin Shan #define NCSI_PACKAGE_INDEX(c) (((c) >> NCSI_PACKAGE_SHIFT) & 0x7) 200bc7e0f50SGavin Shan #define NCSI_RESERVED_CHANNEL 0x1f 2012d283bddSGavin Shan #define NCSI_CHANNEL_INDEX(c) ((c) & ((1 << NCSI_PACKAGE_SHIFT) - 1)) 2022d283bddSGavin Shan #define NCSI_TO_CHANNEL(p, c) (((p) << NCSI_PACKAGE_SHIFT) | (c)) 2039771b8ccSJustin.Lee1@Dell.com #define NCSI_MAX_PACKAGE 8 2049771b8ccSJustin.Lee1@Dell.com #define NCSI_MAX_CHANNEL 32 2052d283bddSGavin Shan 2062d283bddSGavin Shan struct ncsi_channel { 2072d283bddSGavin Shan unsigned char id; 2082d283bddSGavin Shan int state; 2092d283bddSGavin Shan #define NCSI_CHANNEL_INACTIVE 1 2102d283bddSGavin Shan #define NCSI_CHANNEL_ACTIVE 2 211e6f44ed6SGavin Shan #define NCSI_CHANNEL_INVISIBLE 3 21221acf630SSamuel Mendoza-Jonas bool reconfigure_needed; 2132d283bddSGavin Shan spinlock_t lock; /* Protect filters etc */ 2142d283bddSGavin Shan struct ncsi_package *package; 2152d283bddSGavin Shan struct ncsi_channel_version version; 2162d283bddSGavin Shan struct ncsi_channel_cap caps[NCSI_CAP_MAX]; 2172d283bddSGavin Shan struct ncsi_channel_mode modes[NCSI_MODE_MAX]; 218062b3e1bSSamuel Mendoza-Jonas /* Filtering Settings */ 219062b3e1bSSamuel Mendoza-Jonas struct ncsi_channel_mac_filter mac_filter; 220062b3e1bSSamuel Mendoza-Jonas struct ncsi_channel_vlan_filter vlan_filter; 2212d283bddSGavin Shan struct ncsi_channel_stats stats; 22283afdc6aSGavin Shan struct { 22383afdc6aSGavin Shan struct timer_list timer; 22483afdc6aSGavin Shan bool enabled; 22583afdc6aSGavin Shan unsigned int state; 22683afdc6aSGavin Shan #define NCSI_CHANNEL_MONITOR_START 0 22783afdc6aSGavin Shan #define NCSI_CHANNEL_MONITOR_RETRY 1 22883afdc6aSGavin Shan #define NCSI_CHANNEL_MONITOR_WAIT 2 22983afdc6aSGavin Shan #define NCSI_CHANNEL_MONITOR_WAIT_MAX 5 23083afdc6aSGavin Shan } monitor; 2312d283bddSGavin Shan struct list_head node; 232e6f44ed6SGavin Shan struct list_head link; 2332d283bddSGavin Shan }; 2342d283bddSGavin Shan 2352d283bddSGavin Shan struct ncsi_package { 2362d283bddSGavin Shan unsigned char id; /* NCSI 3-bits package ID */ 2372d283bddSGavin Shan unsigned char uuid[16]; /* UUID */ 2382d283bddSGavin Shan struct ncsi_dev_priv *ndp; /* NCSI device */ 2392d283bddSGavin Shan spinlock_t lock; /* Protect the package */ 2402d283bddSGavin Shan unsigned int channel_num; /* Number of channels */ 241*4fb3ebbfSZheng Yongjun struct list_head channels; /* List of channels */ 2422d283bddSGavin Shan struct list_head node; /* Form list of packages */ 2438d951a75SSamuel Mendoza-Jonas 2448d951a75SSamuel Mendoza-Jonas bool multi_channel; /* Enable multiple channels */ 2458d951a75SSamuel Mendoza-Jonas u32 channel_whitelist; /* Channels to configure */ 2468d951a75SSamuel Mendoza-Jonas struct ncsi_channel *preferred_channel; /* Primary channel */ 2472d283bddSGavin Shan }; 2482d283bddSGavin Shan 2492d283bddSGavin Shan struct ncsi_request { 2502d283bddSGavin Shan unsigned char id; /* Request ID - 0 to 255 */ 2512d283bddSGavin Shan bool used; /* Request that has been assigned */ 252a0509cbeSGavin Shan unsigned int flags; /* NCSI request property */ 253a0509cbeSGavin Shan #define NCSI_REQ_FLAG_EVENT_DRIVEN 1 2549771b8ccSJustin.Lee1@Dell.com #define NCSI_REQ_FLAG_NETLINK_DRIVEN 2 2552d283bddSGavin Shan struct ncsi_dev_priv *ndp; /* Associated NCSI device */ 2562d283bddSGavin Shan struct sk_buff *cmd; /* Associated NCSI command packet */ 2572d283bddSGavin Shan struct sk_buff *rsp; /* Associated NCSI response packet */ 2582d283bddSGavin Shan struct timer_list timer; /* Timer on waiting for response */ 2592d283bddSGavin Shan bool enabled; /* Time has been enabled or not */ 2609771b8ccSJustin.Lee1@Dell.com u32 snd_seq; /* netlink sending sequence number */ 2619771b8ccSJustin.Lee1@Dell.com u32 snd_portid; /* netlink portid of sender */ 2629771b8ccSJustin.Lee1@Dell.com struct nlmsghdr nlhdr; /* netlink message header */ 2632d283bddSGavin Shan }; 2642d283bddSGavin Shan 265e6f44ed6SGavin Shan enum { 266e6f44ed6SGavin Shan ncsi_dev_state_major = 0xff00, 267e6f44ed6SGavin Shan ncsi_dev_state_minor = 0x00ff, 268e6f44ed6SGavin Shan ncsi_dev_state_probe_deselect = 0x0201, 269e6f44ed6SGavin Shan ncsi_dev_state_probe_package, 270e6f44ed6SGavin Shan ncsi_dev_state_probe_channel, 2715e0fcc16SVijay Khemka ncsi_dev_state_probe_mlx_gma, 2725e0fcc16SVijay Khemka ncsi_dev_state_probe_mlx_smaf, 273e6f44ed6SGavin Shan ncsi_dev_state_probe_cis, 274e6f44ed6SGavin Shan ncsi_dev_state_probe_gvi, 275e6f44ed6SGavin Shan ncsi_dev_state_probe_gc, 276e6f44ed6SGavin Shan ncsi_dev_state_probe_gls, 277e6f44ed6SGavin Shan ncsi_dev_state_probe_dp, 278e6f44ed6SGavin Shan ncsi_dev_state_config_sp = 0x0301, 279e6f44ed6SGavin Shan ncsi_dev_state_config_cis, 280cb10c7c0SVijay Khemka ncsi_dev_state_config_oem_gma, 28121acf630SSamuel Mendoza-Jonas ncsi_dev_state_config_clear_vids, 28221acf630SSamuel Mendoza-Jonas ncsi_dev_state_config_svf, 28321acf630SSamuel Mendoza-Jonas ncsi_dev_state_config_ev, 284e6f44ed6SGavin Shan ncsi_dev_state_config_sma, 285e6f44ed6SGavin Shan ncsi_dev_state_config_ebf, 286cf0eba33SVijay Khemka ncsi_dev_state_config_dgmf, 287e6f44ed6SGavin Shan ncsi_dev_state_config_ecnt, 288e6f44ed6SGavin Shan ncsi_dev_state_config_ec, 289e6f44ed6SGavin Shan ncsi_dev_state_config_ae, 290e6f44ed6SGavin Shan ncsi_dev_state_config_gls, 291e6f44ed6SGavin Shan ncsi_dev_state_config_done, 292e6f44ed6SGavin Shan ncsi_dev_state_suspend_select = 0x0401, 293008a424aSGavin Shan ncsi_dev_state_suspend_gls, 294e6f44ed6SGavin Shan ncsi_dev_state_suspend_dcnt, 295e6f44ed6SGavin Shan ncsi_dev_state_suspend_dc, 296e6f44ed6SGavin Shan ncsi_dev_state_suspend_deselect, 297e6f44ed6SGavin Shan ncsi_dev_state_suspend_done 298e6f44ed6SGavin Shan }; 299e6f44ed6SGavin Shan 30021acf630SSamuel Mendoza-Jonas struct vlan_vid { 30121acf630SSamuel Mendoza-Jonas struct list_head list; 30221acf630SSamuel Mendoza-Jonas __be16 proto; 30321acf630SSamuel Mendoza-Jonas u16 vid; 30421acf630SSamuel Mendoza-Jonas }; 30521acf630SSamuel Mendoza-Jonas 3062d283bddSGavin Shan struct ncsi_dev_priv { 3072d283bddSGavin Shan struct ncsi_dev ndev; /* Associated NCSI device */ 3082d283bddSGavin Shan unsigned int flags; /* NCSI device flags */ 309e6f44ed6SGavin Shan #define NCSI_DEV_PROBED 1 /* Finalized NCSI topology */ 310e6f44ed6SGavin Shan #define NCSI_DEV_HWA 2 /* Enabled HW arbitration */ 311e6f44ed6SGavin Shan #define NCSI_DEV_RESHUFFLE 4 3122878a2cfSSamuel Mendoza-Jonas #define NCSI_DEV_RESET 8 /* Reset state of NC */ 313cb10c7c0SVijay Khemka unsigned int gma_flag; /* OEM GMA flag */ 3142d283bddSGavin Shan spinlock_t lock; /* Protect the NCSI device */ 3158e13f70bSSamuel Mendoza-Jonas unsigned int package_probe_id;/* Current ID during probe */ 3162d283bddSGavin Shan unsigned int package_num; /* Number of packages */ 3172d283bddSGavin Shan struct list_head packages; /* List of packages */ 318bbc7c01eSGavin Shan struct ncsi_channel *hot_channel; /* Channel was ever active */ 3192d283bddSGavin Shan struct ncsi_request requests[256]; /* Request table */ 3202d283bddSGavin Shan unsigned int request_id; /* Last used request ID */ 321a15af54fSGavin Shan #define NCSI_REQ_START_IDX 1 322e6f44ed6SGavin Shan unsigned int pending_req_num; /* Number of pending requests */ 323e6f44ed6SGavin Shan struct ncsi_package *active_package; /* Currently handled package */ 324e6f44ed6SGavin Shan struct ncsi_channel *active_channel; /* Currently handled channel */ 325e6f44ed6SGavin Shan struct list_head channel_queue; /* Config queue of channels */ 326e6f44ed6SGavin Shan struct work_struct work; /* For channel management */ 327e6f44ed6SGavin Shan struct packet_type ptype; /* NCSI packet Rx handler */ 3282d283bddSGavin Shan struct list_head node; /* Form NCSI device list */ 3296e9c0075SSamuel Mendoza-Jonas #define NCSI_MAX_VLAN_VIDS 15 33021acf630SSamuel Mendoza-Jonas struct list_head vlan_vids; /* List of active VLAN IDs */ 3318d951a75SSamuel Mendoza-Jonas 3328d951a75SSamuel Mendoza-Jonas bool multi_package; /* Enable multiple packages */ 3335e0fcc16SVijay Khemka bool mlx_multi_host; /* Enable multi host Mellanox */ 3348d951a75SSamuel Mendoza-Jonas u32 package_whitelist; /* Packages to configure */ 3352d283bddSGavin Shan }; 3362d283bddSGavin Shan 3376389eaa7SGavin Shan struct ncsi_cmd_arg { 3386389eaa7SGavin Shan struct ncsi_dev_priv *ndp; /* Associated NCSI device */ 3396389eaa7SGavin Shan unsigned char type; /* Command in the NCSI packet */ 3406389eaa7SGavin Shan unsigned char id; /* Request ID (sequence number) */ 3416389eaa7SGavin Shan unsigned char package; /* Destination package ID */ 342*4fb3ebbfSZheng Yongjun unsigned char channel; /* Destination channel ID or 0x1f */ 3436389eaa7SGavin Shan unsigned short payload; /* Command packet payload length */ 344a0509cbeSGavin Shan unsigned int req_flags; /* NCSI request properties */ 3456389eaa7SGavin Shan union { 3466389eaa7SGavin Shan unsigned char bytes[16]; /* Command packet specific data */ 3476389eaa7SGavin Shan unsigned short words[8]; 3486389eaa7SGavin Shan unsigned int dwords[4]; 3496389eaa7SGavin Shan }; 350fb4ee675SVijay Khemka unsigned char *data; /* NCSI OEM data */ 3519771b8ccSJustin.Lee1@Dell.com struct genl_info *info; /* Netlink information */ 3526389eaa7SGavin Shan }; 3536389eaa7SGavin Shan 3542d283bddSGavin Shan extern struct list_head ncsi_dev_list; 3552d283bddSGavin Shan extern spinlock_t ncsi_dev_lock; 3562d283bddSGavin Shan 3572d283bddSGavin Shan #define TO_NCSI_DEV_PRIV(nd) \ 3582d283bddSGavin Shan container_of(nd, struct ncsi_dev_priv, ndev) 3592d283bddSGavin Shan #define NCSI_FOR_EACH_DEV(ndp) \ 3602d283bddSGavin Shan list_for_each_entry_rcu(ndp, &ncsi_dev_list, node) 3612d283bddSGavin Shan #define NCSI_FOR_EACH_PACKAGE(ndp, np) \ 3622d283bddSGavin Shan list_for_each_entry_rcu(np, &ndp->packages, node) 3632d283bddSGavin Shan #define NCSI_FOR_EACH_CHANNEL(np, nc) \ 3642d283bddSGavin Shan list_for_each_entry_rcu(nc, &np->channels, node) 3652d283bddSGavin Shan 3662d283bddSGavin Shan /* Resources */ 3672878a2cfSSamuel Mendoza-Jonas int ncsi_reset_dev(struct ncsi_dev *nd); 368e6f44ed6SGavin Shan void ncsi_start_channel_monitor(struct ncsi_channel *nc); 369e6f44ed6SGavin Shan void ncsi_stop_channel_monitor(struct ncsi_channel *nc); 3702d283bddSGavin Shan struct ncsi_channel *ncsi_find_channel(struct ncsi_package *np, 3712d283bddSGavin Shan unsigned char id); 3722d283bddSGavin Shan struct ncsi_channel *ncsi_add_channel(struct ncsi_package *np, 3732d283bddSGavin Shan unsigned char id); 3742d283bddSGavin Shan struct ncsi_package *ncsi_find_package(struct ncsi_dev_priv *ndp, 3752d283bddSGavin Shan unsigned char id); 3762d283bddSGavin Shan struct ncsi_package *ncsi_add_package(struct ncsi_dev_priv *ndp, 3772d283bddSGavin Shan unsigned char id); 3782d283bddSGavin Shan void ncsi_remove_package(struct ncsi_package *np); 3792d283bddSGavin Shan void ncsi_find_package_and_channel(struct ncsi_dev_priv *ndp, 3802d283bddSGavin Shan unsigned char id, 3812d283bddSGavin Shan struct ncsi_package **np, 3822d283bddSGavin Shan struct ncsi_channel **nc); 383a0509cbeSGavin Shan struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp, 384a0509cbeSGavin Shan unsigned int req_flags); 3852d283bddSGavin Shan void ncsi_free_request(struct ncsi_request *nr); 3862d283bddSGavin Shan struct ncsi_dev *ncsi_find_dev(struct net_device *dev); 387e6f44ed6SGavin Shan int ncsi_process_next_channel(struct ncsi_dev_priv *ndp); 3888d951a75SSamuel Mendoza-Jonas bool ncsi_channel_has_link(struct ncsi_channel *channel); 3898d951a75SSamuel Mendoza-Jonas bool ncsi_channel_is_last(struct ncsi_dev_priv *ndp, 3908d951a75SSamuel Mendoza-Jonas struct ncsi_channel *channel); 3918d951a75SSamuel Mendoza-Jonas int ncsi_update_tx_channel(struct ncsi_dev_priv *ndp, 3928d951a75SSamuel Mendoza-Jonas struct ncsi_package *np, 3938d951a75SSamuel Mendoza-Jonas struct ncsi_channel *disable, 3948d951a75SSamuel Mendoza-Jonas struct ncsi_channel *enable); 3952d283bddSGavin Shan 3966389eaa7SGavin Shan /* Packet handlers */ 3976389eaa7SGavin Shan u32 ncsi_calculate_checksum(unsigned char *data, int len); 3986389eaa7SGavin Shan int ncsi_xmit_cmd(struct ncsi_cmd_arg *nca); 399138635ccSGavin Shan int ncsi_rcv_rsp(struct sk_buff *skb, struct net_device *dev, 400138635ccSGavin Shan struct packet_type *pt, struct net_device *orig_dev); 4017a82ecf4SGavin Shan int ncsi_aen_handler(struct ncsi_dev_priv *ndp, struct sk_buff *skb); 4026389eaa7SGavin Shan 4032d283bddSGavin Shan #endif /* __NCSI_INTERNAL_H__ */ 404