Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
bnx2x_sp.h
Go to the documentation of this file.
1 /* bnx2x_sp.h: Broadcom Everest network driver.
2  *
3  * Copyright (c) 2011-2012 Broadcom Corporation
4  *
5  * Unless you and Broadcom execute a separate written software license
6  * agreement governing use of this software, this software is licensed to you
7  * under the terms of the GNU General Public License version 2, available
8  * at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL").
9  *
10  * Notwithstanding the above, under no circumstances may you combine this
11  * software in any way with any other Broadcom software provided under a
12  * license other than the GPL, without Broadcom's express prior written
13  * consent.
14  *
15  * Maintained by: Eilon Greenstein <[email protected]>
16  * Written by: Vladislav Zolotarov
17  *
18  */
19 #ifndef BNX2X_SP_VERBS
20 #define BNX2X_SP_VERBS
21 
22 struct bnx2x;
23 struct eth_context;
24 
25 /* Bits representing general command's configuration */
26 enum {
29  /* Wait until all pending commands complete */
31  /* Don't send a ramrod, only update a registry */
33  /* Configure HW according to the current object state */
35  /* Execute the next command now */
37  /*
38  * Don't add a new command and continue execution of posponed
39  * commands. If not set a new command will be added to the
40  * pending commands list.
41  */
43 };
44 
45 typedef enum {
50 
51 /* Filtering states */
52 enum {
67 };
68 
69 struct bnx2x_raw_obj {
71 
72  /* Queue params */
75 
76  /* Ramrod data buffer params */
77  void *rdata;
79 
80  /* Ramrod state params */
81  int state; /* "ramrod is pending" state bit */
82  unsigned long *pstate; /* pointer to state buffer */
83 
85 
86  int (*wait_comp)(struct bnx2x *bp,
87  struct bnx2x_raw_obj *o);
88 
92 };
93 
94 /************************* VLAN-MAC commands related parameters ***************/
97 };
98 
101 };
102 
106 };
107 
112 };
113 
114 /* VLAN_MAC commands */
119 };
120 
122  /* Requested command: BNX2X_VLAN_MAC_XX */
124  /*
125  * used to contain the data related vlan_mac_flags bits from
126  * ramrod parameters.
127  */
128  unsigned long vlan_mac_flags;
129 
130  /* Needed for MOVE command */
132 
134 };
135 
136 /*************************** Exe Queue obj ************************************/
139 
140  struct {
141  /* TODO */
142  } mcast;
143 };
144 
146  struct list_head link;
147 
148  /* Length of this element in the exe_chunk. */
149  int cmd_len;
150 
152 };
153 
154 union bnx2x_qable_obj;
155 
158 };
159 
160 struct bnx2x_exe_queue_obj;
161 
162 typedef int (*exe_q_validate)(struct bnx2x *bp,
163  union bnx2x_qable_obj *o,
164  struct bnx2x_exeq_elem *elem);
165 
166 typedef int (*exe_q_remove)(struct bnx2x *bp,
167  union bnx2x_qable_obj *o,
168  struct bnx2x_exeq_elem *elem);
169 
170 /* Return positive if entry was optimized, 0 - if not, negative
171  * in case of an error.
172  */
173 typedef int (*exe_q_optimize)(struct bnx2x *bp,
174  union bnx2x_qable_obj *o,
175  struct bnx2x_exeq_elem *elem);
176 typedef int (*exe_q_execute)(struct bnx2x *bp,
177  union bnx2x_qable_obj *o,
178  struct list_head *exe_chunk,
179  unsigned long *ramrod_flags);
180 typedef struct bnx2x_exeq_elem *
181  (*exe_q_get)(struct bnx2x_exe_queue_obj *o,
182  struct bnx2x_exeq_elem *elem);
183 
185  /*
186  * Commands pending for an execution.
187  */
189 
190  /*
191  * Commands pending for an completion.
192  */
194 
196 
197  /* Maximum length of commands' list for one execution */
199 
201 
202  /****** Virtual functions ******/
210 
215  exe_q_remove remove;
216 
226 
231 
237 };
238 /***************** Classification verbs: Set/Del MAC/VLAN/VLAN-MAC ************/
239 /*
240  * Element in the VLAN_MAC registry list having all currenty configured
241  * rules.
242  */
244  struct list_head link;
245 
246  /*
247  * Used to store the cam offset used for the mac/vlan/vlan-mac.
248  * Relevant for 57710 and 57711 only. VLANs and MACs share the
249  * same CAM for these chips.
250  */
252 
253  /* Needed for DEL and RESTORE flows */
254  unsigned long vlan_mac_flags;
255 
257 };
258 
259 /* Bits representing VLAN_MAC commands specific flags */
260 enum {
267 };
268 
270  /* Object to run the command from */
272 
273  /* General command flags: COMP_WAIT, etc. */
274  unsigned long ramrod_flags;
275 
276  /* Command specific configuration request */
278 };
279 
282 
283  /* Bookkeeping list: will prevent the addition of already existing
284  * entries.
285  */
286  struct list_head head;
287 
288  /* TODO: Add it's initialization in the init functions */
290 
291  /* MACs credit pool */
293 
294  /* VLANs credit pool */
296 
297  /* RAMROD command to be used */
299 
300  /* copy first n elements onto preallocated buffer
301  *
302  * @param n number of elements to get
303  * @param buf buffer preallocated by caller into which elements
304  * will be copied. Note elements are 4-byte aligned
305  * so buffer size must be able to accomodate the
306  * aligned elements.
307  *
308  * @return number of copied bytes
309  */
310  int (*get_n_elements)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o,
311  int n, u8 *buf);
312 
319  int (*check_add)(struct bnx2x *bp,
320  struct bnx2x_vlan_mac_obj *o,
322 
329  (*check_del)(struct bnx2x *bp,
330  struct bnx2x_vlan_mac_obj *o,
332 
338  bool (*check_move)(struct bnx2x *bp,
339  struct bnx2x_vlan_mac_obj *src_o,
340  struct bnx2x_vlan_mac_obj *dst_o,
342 
351 
355  void (*set_one_rule)(struct bnx2x *bp,
356  struct bnx2x_vlan_mac_obj *o,
357  struct bnx2x_exeq_elem *elem, int rule_idx,
358  int cam_offset);
359 
377  int (*delete_all)(struct bnx2x *bp,
378  struct bnx2x_vlan_mac_obj *o,
379  unsigned long *vlan_mac_flags,
380  unsigned long *ramrod_flags);
381 
397  int (*restore)(struct bnx2x *bp,
399  struct bnx2x_vlan_mac_registry_elem **ppos);
400 
418  int (*complete)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o,
419  union event_ring_elem *cqe,
420  unsigned long *ramrod_flags);
421 
427  int (*wait)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o);
428 };
429 
430 enum {
434 };
435 
436 void bnx2x_set_mac_in_nig(struct bnx2x *bp,
437  bool add, unsigned char *dev_addr, int index);
438 
441 /* RX_MODE ramrod spesial flags: set in rx_mode_flags field in
442  * a bnx2x_rx_mode_ramrod_params.
443  */
444 enum {
447 };
448 
449 enum {
457 };
458 
461  unsigned long *pstate;
462  int state;
466  unsigned long ramrod_flags;
467  unsigned long rx_mode_flags;
468 
469  /*
470  * rdata is either a pointer to eth_filter_rules_ramrod_data(e2) or to
471  * a tstorm_eth_mac_filter_config (e1x).
472  */
473  void *rdata;
475 
476  /* Rx mode settings */
477  unsigned long rx_accept_flags;
478 
479  /* internal switching settings */
480  unsigned long tx_accept_flags;
481 };
482 
484  int (*config_rx_mode)(struct bnx2x *bp,
486 
487  int (*wait_comp)(struct bnx2x *bp,
489 };
490 
491 /********************** Set multicast group ***********************************/
492 
494  struct list_head link;
495  u8 *mac;
496 };
497 
499  u8 *mac;
500  u8 bin; /* used in a RESTORE flow */
501 };
502 
505 
506  /* Relevant options are RAMROD_COMP_WAIT and RAMROD_DRV_CLR_ONLY */
507  unsigned long ramrod_flags;
508 
509  struct list_head mcast_list; /* list of struct bnx2x_mcast_list_elem */
519 };
520 
521 enum {
526 };
527 
530 
531  union {
532  struct {
533  #define BNX2X_MCAST_BINS_NUM 256
534  #define BNX2X_MCAST_VEC_SZ (BNX2X_MCAST_BINS_NUM / 64)
536 
542  } aprox_match;
543 
544  struct {
545  struct list_head macs;
547  } exact_match;
548  } registry;
549 
550  /* Pending commands */
552 
553  /* A state that is set in raw.pstate, when there are pending commands */
555 
556  /* Maximal number of mcast MACs configured in one command */
558 
559  /* Total number of currently pending MACs to configure: both
560  * in the pending commands list and in the current command.
561  */
563 
565 
569  int (*config_mcast)(struct bnx2x *bp,
570  struct bnx2x_mcast_ramrod_params *p, int cmd);
571 
583  int (*hdl_restore)(struct bnx2x *bp, struct bnx2x_mcast_obj *o,
584  int start_bin, int *rdata_idx);
585 
586  int (*enqueue_cmd)(struct bnx2x *bp, struct bnx2x_mcast_obj *o,
587  struct bnx2x_mcast_ramrod_params *p, int cmd);
588 
589  void (*set_one_rule)(struct bnx2x *bp,
590  struct bnx2x_mcast_obj *o, int idx,
591  union bnx2x_mcast_config_data *cfg_data, int cmd);
592 
597 
604 
605  /* Wait until all pending commands complete */
606  int (*wait_comp)(struct bnx2x *bp, struct bnx2x_mcast_obj *o);
607 
613  int (*validate)(struct bnx2x *bp,
614  struct bnx2x_mcast_ramrod_params *p, int cmd);
615 
619  void (*revert)(struct bnx2x *bp,
621  int old_num_bins);
622 
625 };
626 
627 /*************************** Credit handling **********************************/
629 
630  /* Current amount of credit in the pool */
632 
633  /* Maximum allowed credit. put() will check against it. */
634  int pool_sz;
635 
636  /*
637  * Allocate a pool table statically.
638  *
639  * Currently the mamimum allowed size is MAX_MAC_CREDIT_E2(272)
640  *
641  * The set bit in the table will mean that the entry is available.
642  */
643 #define BNX2X_POOL_VEC_SIZE (MAX_MAC_CREDIT_E2 / 64)
645 
646  /* Base pool offset (initialized differently */
648 
655 
663 
670  bool (*get)(struct bnx2x_credit_pool_obj *o, int cnt);
671 
678  bool (*put)(struct bnx2x_credit_pool_obj *o, int cnt);
679 
684 };
685 
686 /*************************** RSS configuration ********************************/
687 enum {
688  /* RSS_MODE bits are mutually exclusive */
691 
692  BNX2X_RSS_SET_SRCH, /* Setup searcher, E1x specific flag */
693 
700 };
701 
704 
705  /* may have RAMROD_COMP_WAIT set only */
706  unsigned long ramrod_flags;
707 
708  /* BNX2X_RSS_X bits */
709  unsigned long rss_flags;
710 
711  /* Number hash bits to take into an account */
713 
714  /* Indirection table */
716 
717  /* RSS hash values */
719 
720  /* valid only iff BNX2X_RSS_UPDATE_TOE is set */
722 };
723 
726 
727  /* RSS engine to use */
729 
730  /* Last configured indirection table */
732 
733  /* flags for enabling 4-tupple hash on UDP */
736 
737  int (*config_rss)(struct bnx2x *bp,
738  struct bnx2x_config_rss_params *p);
739 };
740 
741 /*********************** Queue state update ***********************************/
742 
743 /* UPDATE command options */
744 enum {
757 };
758 
759 /* Allowed Queue states */
771 };
772 
773 /* Allowed commands */
787 };
788 
789 /* queue SETUP + INIT flags */
790 enum {
812 };
813 
814 /* Queue type options: queue type may be a compination of below. */
821 };
822 
823 #define BNX2X_PRIMARY_CID_INDEX 0
824 #define BNX2X_MULTI_TX_COS_E1X 3 /* QM only */
825 #define BNX2X_MULTI_TX_COS_E2_E3A0 2
826 #define BNX2X_MULTI_TX_COS_E3B0 3
827 #define BNX2X_MULTI_TX_COS 3 /* Maximum possible */
828 
829 
831  struct {
832  unsigned long flags;
836  } tx;
837 
838  struct {
839  unsigned long flags;
840  u16 hc_rate;
841  u8 fw_sb_id;
842  u8 sb_cq_index;
843  } rx;
844 
845  /* CID context in the host memory */
847 
848  /* maximum number of cos supported by hardware */
850 };
851 
853  /* index within the tx_only cids of this queue object */
855 };
856 
858  /* index within the tx_only cids of this queue object */
860 };
861 
863  unsigned long update_flags; /* BNX2X_Q_UPDATE_XX bits */
867 /* index within the tx_only cids of this queue object */
869 };
870 
876  u16 sge_th_lo; /* valid iff BNX2X_Q_FLG_TPA */
877  u16 sge_th_hi; /* valid iff BNX2X_Q_FLG_TPA */
879 };
880 
881 /* general */
883  /* valid iff BNX2X_Q_FLG_STATS */
885 
889 };
890 
892  /* dma */
897 
902 
903  /* valid iff BNX2X_Q_FLG_TPA */
909 
910  /* valid iff BNX2X_Q_FLG_MCAST */
912 
914 
916 
917  /* valid iff BXN2X_Q_FLG_SILENT_VLAN_REM */
920 };
921 
923  /* dma */
925 
928  u8 cos; /* valid iff BNX2X_Q_FLG_COS */
930  /* equals to the leading rss client id, used for TX classification*/
932 
933  /* valid iff BNX2X_Q_FLG_DEF_VLAN */
935 };
936 
942  unsigned long flags;
943 };
944 
948  unsigned long flags;
949  /* index within the tx_only cids of this queue object */
951 };
952 
955 
956  /* Current command */
958 
959  /* may have RAMROD_COMP_WAIT set only */
960  unsigned long ramrod_flags;
961 
962  /* Params according to the current command */
963  union {
970  } params;
971 };
972 
976 };
977 
982 
983  /*
984  * number of traffic classes supported by queue.
985  * The primary connection of the queue suppotrs the first traffic
986  * class. Any further traffic class is suppoted by a tx-only
987  * connection.
988  *
989  * Therefore max_cos is also a number of valid entries in the cids
990  * array.
991  */
994 
996 
997  /* bits from enum bnx2x_q_type */
998  unsigned long type;
999 
1000  /* BNX2X_Q_CMD_XX bits. This object implements "one
1001  * pending" paradigm but for debug and tracing purposes it's
1002  * more convinient to have different bits for different
1003  * commands.
1004  */
1005  unsigned long pending;
1006 
1007  /* Buffer to use as a ramrod data and its mapping */
1008  void *rdata;
1010 
1016  int (*send_cmd)(struct bnx2x *bp,
1018 
1024 
1028  int (*check_transition)(struct bnx2x *bp,
1029  struct bnx2x_queue_sp_obj *o,
1031 
1035  int (*complete_cmd)(struct bnx2x *bp,
1036  struct bnx2x_queue_sp_obj *o,
1037  enum bnx2x_queue_cmd);
1038 
1039  int (*wait_comp)(struct bnx2x *bp,
1040  struct bnx2x_queue_sp_obj *o,
1041  enum bnx2x_queue_cmd cmd);
1042 };
1043 
1044 /********************** Function state update *********************************/
1045 /* Allowed Function states */
1052 };
1053 
1054 /* Allowed Function commands */
1065 };
1066 
1068  /* A load phase returned by MCP.
1069  *
1070  * May be:
1071  * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
1072  * FW_MSG_CODE_DRV_LOAD_COMMON
1073  * FW_MSG_CODE_DRV_LOAD_PORT
1074  * FW_MSG_CODE_DRV_LOAD_FUNCTION
1075  */
1077 };
1078 
1080  /* A load phase returned by MCP.
1081  *
1082  * May be:
1083  * FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
1084  * FW_MSG_CODE_DRV_LOAD_COMMON
1085  * FW_MSG_CODE_DRV_LOAD_PORT
1086  * FW_MSG_CODE_DRV_LOAD_FUNCTION
1087  */
1089 };
1090 
1092  /* Multi Function mode:
1093  * - Single Function
1094  * - Switch Dependent
1095  * - Switch Independent
1096  */
1098 
1099  /* Switch Dependent mode outer VLAN tag */
1101 
1102  /* Function cos mode */
1104 };
1105 
1110 };
1111 
1117 };
1123 };
1124 
1127 
1128  /* Current command */
1130 
1131  /* may have RAMROD_COMP_WAIT set only */
1132  unsigned long ramrod_flags;
1133 
1134  /* Params according to the current command */
1135  union {
1142  } params;
1143 };
1144 
1146  /* Init tool + runtime initialization:
1147  * - Common Chip
1148  * - Common (per Path)
1149  * - Port
1150  * - Function phases
1151  */
1152  int (*init_hw_cmn_chip)(struct bnx2x *bp);
1153  int (*init_hw_cmn)(struct bnx2x *bp);
1154  int (*init_hw_port)(struct bnx2x *bp);
1155  int (*init_hw_func)(struct bnx2x *bp);
1156 
1157  /* Reset Function HW: Common, Port, Function phases. */
1158  void (*reset_hw_cmn)(struct bnx2x *bp);
1159  void (*reset_hw_port)(struct bnx2x *bp);
1160  void (*reset_hw_func)(struct bnx2x *bp);
1161 
1162  /* Init/Free GUNZIP resources */
1163  int (*gunzip_init)(struct bnx2x *bp);
1164  void (*gunzip_end)(struct bnx2x *bp);
1165 
1166  /* Prepare/Release FW resources */
1167  int (*init_fw)(struct bnx2x *bp);
1168  void (*release_fw)(struct bnx2x *bp);
1169 };
1170 
1173 
1174  /* BNX2X_FUNC_CMD_XX bits. This object implements "one
1175  * pending" paradigm but for debug and tracing purposes it's
1176  * more convinient to have different bits for different
1177  * commands.
1178  */
1179  unsigned long pending;
1180 
1181  /* Buffer to use as a ramrod data and its mapping */
1182  void *rdata;
1184 
1185  /* Buffer to use as a afex ramrod data and its mapping.
1186  * This can't be same rdata as above because afex ramrod requests
1187  * can arrive to the object in parallel to other ramrod requests.
1188  */
1189  void *afex_rdata;
1191 
1192  /* this mutex validates that when pending flag is taken, the next
1193  * ramrod to be sent will be the one set the pending bit
1194  */
1196 
1197  /* Driver interface */
1199 
1205  int (*send_cmd)(struct bnx2x *bp,
1207 
1211  int (*check_transition)(struct bnx2x *bp,
1212  struct bnx2x_func_sp_obj *o,
1214 
1218  int (*complete_cmd)(struct bnx2x *bp,
1219  struct bnx2x_func_sp_obj *o,
1220  enum bnx2x_func_cmd cmd);
1221 
1222  int (*wait_comp)(struct bnx2x *bp, struct bnx2x_func_sp_obj *o,
1223  enum bnx2x_func_cmd cmd);
1224 };
1225 
1226 /********************** Interfaces ********************************************/
1227 /* Queueable objects set */
1230 };
1231 /************** Function state update *********/
1232 void bnx2x_init_func_obj(struct bnx2x *bp,
1233  struct bnx2x_func_sp_obj *obj,
1234  void *rdata, dma_addr_t rdata_mapping,
1235  void *afex_rdata, dma_addr_t afex_rdata_mapping,
1236  struct bnx2x_func_sp_drv_ops *drv_iface);
1237 
1238 int bnx2x_func_state_change(struct bnx2x *bp,
1240 
1242  struct bnx2x_func_sp_obj *o);
1243 /******************* Queue State **************/
1244 void bnx2x_init_queue_obj(struct bnx2x *bp,
1245  struct bnx2x_queue_sp_obj *obj, u8 cl_id, u32 *cids,
1246  u8 cid_cnt, u8 func_id, void *rdata,
1247  dma_addr_t rdata_mapping, unsigned long type);
1248 
1249 int bnx2x_queue_state_change(struct bnx2x *bp,
1251 
1252 /********************* VLAN-MAC ****************/
1253 void bnx2x_init_mac_obj(struct bnx2x *bp,
1254  struct bnx2x_vlan_mac_obj *mac_obj,
1255  u8 cl_id, u32 cid, u8 func_id, void *rdata,
1256  dma_addr_t rdata_mapping, int state,
1257  unsigned long *pstate, bnx2x_obj_type type,
1259 
1260 void bnx2x_init_vlan_obj(struct bnx2x *bp,
1261  struct bnx2x_vlan_mac_obj *vlan_obj,
1262  u8 cl_id, u32 cid, u8 func_id, void *rdata,
1263  dma_addr_t rdata_mapping, int state,
1264  unsigned long *pstate, bnx2x_obj_type type,
1266 
1267 void bnx2x_init_vlan_mac_obj(struct bnx2x *bp,
1268  struct bnx2x_vlan_mac_obj *vlan_mac_obj,
1269  u8 cl_id, u32 cid, u8 func_id, void *rdata,
1270  dma_addr_t rdata_mapping, int state,
1271  unsigned long *pstate, bnx2x_obj_type type,
1274 
1275 int bnx2x_config_vlan_mac(struct bnx2x *bp,
1277 
1278 int bnx2x_vlan_mac_move(struct bnx2x *bp,
1280  struct bnx2x_vlan_mac_obj *dest_o);
1281 
1282 /********************* RX MODE ****************/
1283 
1284 void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
1285  struct bnx2x_rx_mode_obj *o);
1286 
1296 int bnx2x_config_rx_mode(struct bnx2x *bp,
1297  struct bnx2x_rx_mode_ramrod_params *p);
1298 
1299 /****************** MULTICASTS ****************/
1300 
1301 void bnx2x_init_mcast_obj(struct bnx2x *bp,
1302  struct bnx2x_mcast_obj *mcast_obj,
1303  u8 mcast_cl_id, u32 mcast_cid, u8 func_id,
1304  u8 engine_id, void *rdata, dma_addr_t rdata_mapping,
1305  int state, unsigned long *pstate,
1307 
1328 int bnx2x_config_mcast(struct bnx2x *bp,
1329  struct bnx2x_mcast_ramrod_params *p, int cmd);
1330 
1331 /****************** CREDIT POOL ****************/
1332 void bnx2x_init_mac_credit_pool(struct bnx2x *bp,
1333  struct bnx2x_credit_pool_obj *p, u8 func_id,
1334  u8 func_num);
1335 void bnx2x_init_vlan_credit_pool(struct bnx2x *bp,
1336  struct bnx2x_credit_pool_obj *p, u8 func_id,
1337  u8 func_num);
1338 
1339 
1340 /****************** RSS CONFIGURATION ****************/
1341 void bnx2x_init_rss_config_obj(struct bnx2x *bp,
1342  struct bnx2x_rss_config_obj *rss_obj,
1343  u8 cl_id, u32 cid, u8 func_id, u8 engine_id,
1344  void *rdata, dma_addr_t rdata_mapping,
1345  int state, unsigned long *pstate,
1347 
1353 int bnx2x_config_rss(struct bnx2x *bp,
1354  struct bnx2x_config_rss_params *p);
1355 
1363 void bnx2x_get_rss_ind_table(struct bnx2x_rss_config_obj *rss_obj,
1364  u8 *ind_table);
1365 
1366 #endif /* BNX2X_SP_VERBS */