0001
0002
0003
0004
0005
0006 #ifndef __NCSI_INTERNAL_H__
0007 #define __NCSI_INTERNAL_H__
0008
0009 enum {
0010 NCSI_CAP_BASE = 0,
0011 NCSI_CAP_GENERIC = 0,
0012 NCSI_CAP_BC,
0013 NCSI_CAP_MC,
0014 NCSI_CAP_BUFFER,
0015 NCSI_CAP_AEN,
0016 NCSI_CAP_VLAN,
0017 NCSI_CAP_MAX
0018 };
0019
0020 enum {
0021 NCSI_CAP_GENERIC_HWA = 0x01,
0022 NCSI_CAP_GENERIC_HDS = 0x02,
0023 NCSI_CAP_GENERIC_FC = 0x04,
0024 NCSI_CAP_GENERIC_FC1 = 0x08,
0025 NCSI_CAP_GENERIC_MC = 0x10,
0026 NCSI_CAP_GENERIC_HWA_UNKNOWN = 0x00,
0027 NCSI_CAP_GENERIC_HWA_SUPPORT = 0x20,
0028 NCSI_CAP_GENERIC_HWA_NOT_SUPPORT = 0x40,
0029 NCSI_CAP_GENERIC_HWA_RESERVED = 0x60,
0030 NCSI_CAP_GENERIC_HWA_MASK = 0x60,
0031 NCSI_CAP_GENERIC_MASK = 0x7f,
0032 NCSI_CAP_BC_ARP = 0x01,
0033 NCSI_CAP_BC_DHCPC = 0x02,
0034 NCSI_CAP_BC_DHCPS = 0x04,
0035 NCSI_CAP_BC_NETBIOS = 0x08,
0036 NCSI_CAP_BC_MASK = 0x0f,
0037 NCSI_CAP_MC_IPV6_NEIGHBOR = 0x01,
0038 NCSI_CAP_MC_IPV6_ROUTER = 0x02,
0039 NCSI_CAP_MC_DHCPV6_RELAY = 0x04,
0040 NCSI_CAP_MC_DHCPV6_WELL_KNOWN = 0x08,
0041 NCSI_CAP_MC_IPV6_MLD = 0x10,
0042 NCSI_CAP_MC_IPV6_NEIGHBOR_S = 0x20,
0043 NCSI_CAP_MC_MASK = 0x3f,
0044 NCSI_CAP_AEN_LSC = 0x01,
0045 NCSI_CAP_AEN_CR = 0x02,
0046 NCSI_CAP_AEN_HDS = 0x04,
0047 NCSI_CAP_AEN_MASK = 0x07,
0048 NCSI_CAP_VLAN_ONLY = 0x01,
0049 NCSI_CAP_VLAN_NO = 0x02,
0050 NCSI_CAP_VLAN_ANY = 0x04,
0051 NCSI_CAP_VLAN_MASK = 0x07
0052 };
0053
0054 enum {
0055 NCSI_MODE_BASE = 0,
0056 NCSI_MODE_ENABLE = 0,
0057 NCSI_MODE_TX_ENABLE,
0058 NCSI_MODE_LINK,
0059 NCSI_MODE_VLAN,
0060 NCSI_MODE_BC,
0061 NCSI_MODE_MC,
0062 NCSI_MODE_AEN,
0063 NCSI_MODE_FC,
0064 NCSI_MODE_MAX
0065 };
0066
0067
0068
0069
0070
0071
0072
0073 enum {
0074 MLX_MC_RBT_SUPPORT = 0x01,
0075 MLX_MC_RBT_AVL = 0x08,
0076 };
0077
0078
0079 #define NCSI_OEM_MFR_MLX_ID 0x8119
0080 #define NCSI_OEM_MFR_BCM_ID 0x113d
0081 #define NCSI_OEM_MFR_INTEL_ID 0x157
0082
0083 #define NCSI_OEM_INTEL_CMD_GMA 0x06
0084 #define NCSI_OEM_INTEL_CMD_KEEP_PHY 0x20
0085
0086 #define NCSI_OEM_BCM_CMD_GMA 0x01
0087
0088 #define NCSI_OEM_MLX_CMD_GMA 0x00
0089 #define NCSI_OEM_MLX_CMD_GMA_PARAM 0x1b
0090 #define NCSI_OEM_MLX_CMD_SMAF 0x01
0091 #define NCSI_OEM_MLX_CMD_SMAF_PARAM 0x07
0092
0093 #define NCSI_OEM_INTEL_CMD_GMA_LEN 5
0094 #define NCSI_OEM_INTEL_CMD_KEEP_PHY_LEN 7
0095 #define NCSI_OEM_BCM_CMD_GMA_LEN 12
0096 #define NCSI_OEM_MLX_CMD_GMA_LEN 8
0097 #define NCSI_OEM_MLX_CMD_SMAF_LEN 60
0098
0099 #define MLX_SMAF_MAC_ADDR_OFFSET 8
0100 #define MLX_SMAF_MED_SUPPORT_OFFSET 14
0101
0102 #define BCM_MAC_ADDR_OFFSET 28
0103 #define MLX_MAC_ADDR_OFFSET 8
0104 #define INTEL_MAC_ADDR_OFFSET 1
0105
0106
0107 struct ncsi_channel_version {
0108 u32 version;
0109 u32 alpha2;
0110 u8 fw_name[12];
0111 u32 fw_version;
0112 u16 pci_ids[4];
0113 u32 mf_id;
0114 };
0115
0116 struct ncsi_channel_cap {
0117 u32 index;
0118 u32 cap;
0119 };
0120
0121 struct ncsi_channel_mode {
0122 u32 index;
0123 u32 enable;
0124 u32 size;
0125 u32 data[8];
0126 };
0127
0128 struct ncsi_channel_mac_filter {
0129 u8 n_uc;
0130 u8 n_mc;
0131 u8 n_mixed;
0132 u64 bitmap;
0133 unsigned char *addrs;
0134 };
0135
0136 struct ncsi_channel_vlan_filter {
0137 u8 n_vids;
0138 u64 bitmap;
0139 u16 *vids;
0140 };
0141
0142 struct ncsi_channel_stats {
0143 u32 hnc_cnt_hi;
0144 u32 hnc_cnt_lo;
0145 u32 hnc_rx_bytes;
0146 u32 hnc_tx_bytes;
0147 u32 hnc_rx_uc_pkts;
0148 u32 hnc_rx_mc_pkts;
0149 u32 hnc_rx_bc_pkts;
0150 u32 hnc_tx_uc_pkts;
0151 u32 hnc_tx_mc_pkts;
0152 u32 hnc_tx_bc_pkts;
0153 u32 hnc_fcs_err;
0154 u32 hnc_align_err;
0155 u32 hnc_false_carrier;
0156 u32 hnc_runt_pkts;
0157 u32 hnc_jabber_pkts;
0158 u32 hnc_rx_pause_xon;
0159 u32 hnc_rx_pause_xoff;
0160 u32 hnc_tx_pause_xon;
0161 u32 hnc_tx_pause_xoff;
0162 u32 hnc_tx_s_collision;
0163 u32 hnc_tx_m_collision;
0164 u32 hnc_l_collision;
0165 u32 hnc_e_collision;
0166 u32 hnc_rx_ctl_frames;
0167 u32 hnc_rx_64_frames;
0168 u32 hnc_rx_127_frames;
0169 u32 hnc_rx_255_frames;
0170 u32 hnc_rx_511_frames;
0171 u32 hnc_rx_1023_frames;
0172 u32 hnc_rx_1522_frames;
0173 u32 hnc_rx_9022_frames;
0174 u32 hnc_tx_64_frames;
0175 u32 hnc_tx_127_frames;
0176 u32 hnc_tx_255_frames;
0177 u32 hnc_tx_511_frames;
0178 u32 hnc_tx_1023_frames;
0179 u32 hnc_tx_1522_frames;
0180 u32 hnc_tx_9022_frames;
0181 u32 hnc_rx_valid_bytes;
0182 u32 hnc_rx_runt_pkts;
0183 u32 hnc_rx_jabber_pkts;
0184 u32 ncsi_rx_cmds;
0185 u32 ncsi_dropped_cmds;
0186 u32 ncsi_cmd_type_errs;
0187 u32 ncsi_cmd_csum_errs;
0188 u32 ncsi_rx_pkts;
0189 u32 ncsi_tx_pkts;
0190 u32 ncsi_tx_aen_pkts;
0191 u32 pt_tx_pkts;
0192 u32 pt_tx_dropped;
0193 u32 pt_tx_channel_err;
0194 u32 pt_tx_us_err;
0195 u32 pt_rx_pkts;
0196 u32 pt_rx_dropped;
0197 u32 pt_rx_channel_err;
0198 u32 pt_rx_us_err;
0199 u32 pt_rx_os_err;
0200 };
0201
0202 struct ncsi_dev_priv;
0203 struct ncsi_package;
0204
0205 #define NCSI_PACKAGE_SHIFT 5
0206 #define NCSI_PACKAGE_INDEX(c) (((c) >> NCSI_PACKAGE_SHIFT) & 0x7)
0207 #define NCSI_RESERVED_CHANNEL 0x1f
0208 #define NCSI_CHANNEL_INDEX(c) ((c) & ((1 << NCSI_PACKAGE_SHIFT) - 1))
0209 #define NCSI_TO_CHANNEL(p, c) (((p) << NCSI_PACKAGE_SHIFT) | (c))
0210 #define NCSI_MAX_PACKAGE 8
0211 #define NCSI_MAX_CHANNEL 32
0212
0213 struct ncsi_channel {
0214 unsigned char id;
0215 int state;
0216 #define NCSI_CHANNEL_INACTIVE 1
0217 #define NCSI_CHANNEL_ACTIVE 2
0218 #define NCSI_CHANNEL_INVISIBLE 3
0219 bool reconfigure_needed;
0220 spinlock_t lock;
0221 struct ncsi_package *package;
0222 struct ncsi_channel_version version;
0223 struct ncsi_channel_cap caps[NCSI_CAP_MAX];
0224 struct ncsi_channel_mode modes[NCSI_MODE_MAX];
0225
0226 struct ncsi_channel_mac_filter mac_filter;
0227 struct ncsi_channel_vlan_filter vlan_filter;
0228 struct ncsi_channel_stats stats;
0229 struct {
0230 struct timer_list timer;
0231 bool enabled;
0232 unsigned int state;
0233 #define NCSI_CHANNEL_MONITOR_START 0
0234 #define NCSI_CHANNEL_MONITOR_RETRY 1
0235 #define NCSI_CHANNEL_MONITOR_WAIT 2
0236 #define NCSI_CHANNEL_MONITOR_WAIT_MAX 5
0237 } monitor;
0238 struct list_head node;
0239 struct list_head link;
0240 };
0241
0242 struct ncsi_package {
0243 unsigned char id;
0244 unsigned char uuid[16];
0245 struct ncsi_dev_priv *ndp;
0246 spinlock_t lock;
0247 unsigned int channel_num;
0248 struct list_head channels;
0249 struct list_head node;
0250
0251 bool multi_channel;
0252 u32 channel_whitelist;
0253 struct ncsi_channel *preferred_channel;
0254 };
0255
0256 struct ncsi_request {
0257 unsigned char id;
0258 bool used;
0259 unsigned int flags;
0260 #define NCSI_REQ_FLAG_EVENT_DRIVEN 1
0261 #define NCSI_REQ_FLAG_NETLINK_DRIVEN 2
0262 struct ncsi_dev_priv *ndp;
0263 struct sk_buff *cmd;
0264 struct sk_buff *rsp;
0265 struct timer_list timer;
0266 bool enabled;
0267 u32 snd_seq;
0268 u32 snd_portid;
0269 struct nlmsghdr nlhdr;
0270 };
0271
0272 enum {
0273 ncsi_dev_state_major = 0xff00,
0274 ncsi_dev_state_minor = 0x00ff,
0275 ncsi_dev_state_probe_deselect = 0x0201,
0276 ncsi_dev_state_probe_package,
0277 ncsi_dev_state_probe_channel,
0278 ncsi_dev_state_probe_mlx_gma,
0279 ncsi_dev_state_probe_mlx_smaf,
0280 ncsi_dev_state_probe_cis,
0281 ncsi_dev_state_probe_keep_phy,
0282 ncsi_dev_state_probe_gvi,
0283 ncsi_dev_state_probe_gc,
0284 ncsi_dev_state_probe_gls,
0285 ncsi_dev_state_probe_dp,
0286 ncsi_dev_state_config_sp = 0x0301,
0287 ncsi_dev_state_config_cis,
0288 ncsi_dev_state_config_oem_gma,
0289 ncsi_dev_state_config_clear_vids,
0290 ncsi_dev_state_config_svf,
0291 ncsi_dev_state_config_ev,
0292 ncsi_dev_state_config_sma,
0293 ncsi_dev_state_config_ebf,
0294 ncsi_dev_state_config_dgmf,
0295 ncsi_dev_state_config_ecnt,
0296 ncsi_dev_state_config_ec,
0297 ncsi_dev_state_config_ae,
0298 ncsi_dev_state_config_gls,
0299 ncsi_dev_state_config_done,
0300 ncsi_dev_state_suspend_select = 0x0401,
0301 ncsi_dev_state_suspend_gls,
0302 ncsi_dev_state_suspend_dcnt,
0303 ncsi_dev_state_suspend_dc,
0304 ncsi_dev_state_suspend_deselect,
0305 ncsi_dev_state_suspend_done
0306 };
0307
0308 struct vlan_vid {
0309 struct list_head list;
0310 __be16 proto;
0311 u16 vid;
0312 };
0313
0314 struct ncsi_dev_priv {
0315 struct ncsi_dev ndev;
0316 unsigned int flags;
0317 #define NCSI_DEV_PROBED 1
0318 #define NCSI_DEV_HWA 2
0319 #define NCSI_DEV_RESHUFFLE 4
0320 #define NCSI_DEV_RESET 8
0321 unsigned int gma_flag;
0322 spinlock_t lock;
0323 unsigned int package_probe_id;
0324 unsigned int package_num;
0325 struct list_head packages;
0326 struct ncsi_channel *hot_channel;
0327 struct ncsi_request requests[256];
0328 unsigned int request_id;
0329 #define NCSI_REQ_START_IDX 1
0330 unsigned int pending_req_num;
0331 struct ncsi_package *active_package;
0332 struct ncsi_channel *active_channel;
0333 struct list_head channel_queue;
0334 struct work_struct work;
0335 struct packet_type ptype;
0336 struct list_head node;
0337 #define NCSI_MAX_VLAN_VIDS 15
0338 struct list_head vlan_vids;
0339
0340 bool multi_package;
0341 bool mlx_multi_host;
0342 u32 package_whitelist;
0343 };
0344
0345 struct ncsi_cmd_arg {
0346 struct ncsi_dev_priv *ndp;
0347 unsigned char type;
0348 unsigned char id;
0349 unsigned char package;
0350 unsigned char channel;
0351 unsigned short payload;
0352 unsigned int req_flags;
0353 union {
0354 unsigned char bytes[16];
0355 unsigned short words[8];
0356 unsigned int dwords[4];
0357 };
0358 unsigned char *data;
0359 struct genl_info *info;
0360 };
0361
0362 extern struct list_head ncsi_dev_list;
0363 extern spinlock_t ncsi_dev_lock;
0364
0365 #define TO_NCSI_DEV_PRIV(nd) \
0366 container_of(nd, struct ncsi_dev_priv, ndev)
0367 #define NCSI_FOR_EACH_DEV(ndp) \
0368 list_for_each_entry_rcu(ndp, &ncsi_dev_list, node)
0369 #define NCSI_FOR_EACH_PACKAGE(ndp, np) \
0370 list_for_each_entry_rcu(np, &ndp->packages, node)
0371 #define NCSI_FOR_EACH_CHANNEL(np, nc) \
0372 list_for_each_entry_rcu(nc, &np->channels, node)
0373
0374
0375 int ncsi_reset_dev(struct ncsi_dev *nd);
0376 void ncsi_start_channel_monitor(struct ncsi_channel *nc);
0377 void ncsi_stop_channel_monitor(struct ncsi_channel *nc);
0378 struct ncsi_channel *ncsi_find_channel(struct ncsi_package *np,
0379 unsigned char id);
0380 struct ncsi_channel *ncsi_add_channel(struct ncsi_package *np,
0381 unsigned char id);
0382 struct ncsi_package *ncsi_find_package(struct ncsi_dev_priv *ndp,
0383 unsigned char id);
0384 struct ncsi_package *ncsi_add_package(struct ncsi_dev_priv *ndp,
0385 unsigned char id);
0386 void ncsi_remove_package(struct ncsi_package *np);
0387 void ncsi_find_package_and_channel(struct ncsi_dev_priv *ndp,
0388 unsigned char id,
0389 struct ncsi_package **np,
0390 struct ncsi_channel **nc);
0391 struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp,
0392 unsigned int req_flags);
0393 void ncsi_free_request(struct ncsi_request *nr);
0394 struct ncsi_dev *ncsi_find_dev(struct net_device *dev);
0395 int ncsi_process_next_channel(struct ncsi_dev_priv *ndp);
0396 bool ncsi_channel_has_link(struct ncsi_channel *channel);
0397 bool ncsi_channel_is_last(struct ncsi_dev_priv *ndp,
0398 struct ncsi_channel *channel);
0399 int ncsi_update_tx_channel(struct ncsi_dev_priv *ndp,
0400 struct ncsi_package *np,
0401 struct ncsi_channel *disable,
0402 struct ncsi_channel *enable);
0403
0404
0405 u32 ncsi_calculate_checksum(unsigned char *data, int len);
0406 int ncsi_xmit_cmd(struct ncsi_cmd_arg *nca);
0407 int ncsi_rcv_rsp(struct sk_buff *skb, struct net_device *dev,
0408 struct packet_type *pt, struct net_device *orig_dev);
0409 int ncsi_aen_handler(struct ncsi_dev_priv *ndp, struct sk_buff *skb);
0410
0411 #endif