bnx2x_dcb.c 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517
  1. /* bnx2x_dcb.c: Broadcom Everest network driver.
  2. *
  3. * Copyright 2009-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 <eilong@broadcom.com>
  16. * Written by: Dmitry Kravkov
  17. *
  18. */
  19. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  20. #include <linux/netdevice.h>
  21. #include <linux/types.h>
  22. #include <linux/errno.h>
  23. #include <linux/rtnetlink.h>
  24. #include <net/dcbnl.h>
  25. #include "bnx2x.h"
  26. #include "bnx2x_cmn.h"
  27. #include "bnx2x_dcb.h"
  28. /* forward declarations of dcbx related functions */
  29. static int bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp);
  30. static void bnx2x_pfc_set_pfc(struct bnx2x *bp);
  31. static void bnx2x_dcbx_update_ets_params(struct bnx2x *bp);
  32. static int bnx2x_dcbx_resume_hw_tx(struct bnx2x *bp);
  33. static void bnx2x_dcbx_get_ets_pri_pg_tbl(struct bnx2x *bp,
  34. u32 *set_configuration_ets_pg,
  35. u32 *pri_pg_tbl);
  36. static void bnx2x_dcbx_get_num_pg_traf_type(struct bnx2x *bp,
  37. u32 *pg_pri_orginal_spread,
  38. struct pg_help_data *help_data);
  39. static void bnx2x_dcbx_fill_cos_params(struct bnx2x *bp,
  40. struct pg_help_data *help_data,
  41. struct dcbx_ets_feature *ets,
  42. u32 *pg_pri_orginal_spread);
  43. static void bnx2x_dcbx_separate_pauseable_from_non(struct bnx2x *bp,
  44. struct cos_help_data *cos_data,
  45. u32 *pg_pri_orginal_spread,
  46. struct dcbx_ets_feature *ets);
  47. static void bnx2x_dcbx_fw_struct(struct bnx2x *bp,
  48. struct bnx2x_func_tx_start_params*);
  49. /* helpers: read/write len bytes from addr into buff by REG_RD/REG_WR */
  50. static void bnx2x_read_data(struct bnx2x *bp, u32 *buff,
  51. u32 addr, u32 len)
  52. {
  53. int i;
  54. for (i = 0; i < len; i += 4, buff++)
  55. *buff = REG_RD(bp, addr + i);
  56. }
  57. static void bnx2x_write_data(struct bnx2x *bp, u32 *buff,
  58. u32 addr, u32 len)
  59. {
  60. int i;
  61. for (i = 0; i < len; i += 4, buff++)
  62. REG_WR(bp, addr + i, *buff);
  63. }
  64. static void bnx2x_pfc_set(struct bnx2x *bp)
  65. {
  66. struct bnx2x_nig_brb_pfc_port_params pfc_params = {0};
  67. u32 pri_bit, val = 0;
  68. int i;
  69. pfc_params.num_of_rx_cos_priority_mask =
  70. bp->dcbx_port_params.ets.num_of_cos;
  71. /* Tx COS configuration */
  72. for (i = 0; i < bp->dcbx_port_params.ets.num_of_cos; i++)
  73. /*
  74. * We configure only the pauseable bits (non pauseable aren't
  75. * configured at all) it's done to avoid false pauses from
  76. * network
  77. */
  78. pfc_params.rx_cos_priority_mask[i] =
  79. bp->dcbx_port_params.ets.cos_params[i].pri_bitmask
  80. & DCBX_PFC_PRI_PAUSE_MASK(bp);
  81. /*
  82. * Rx COS configuration
  83. * Changing PFC RX configuration .
  84. * In RX COS0 will always be configured to lossless and COS1 to lossy
  85. */
  86. for (i = 0 ; i < MAX_PFC_PRIORITIES ; i++) {
  87. pri_bit = 1 << i;
  88. if (!(pri_bit & DCBX_PFC_PRI_PAUSE_MASK(bp)))
  89. val |= 1 << (i * 4);
  90. }
  91. pfc_params.pkt_priority_to_cos = val;
  92. /* RX COS0 */
  93. pfc_params.llfc_low_priority_classes = DCBX_PFC_PRI_PAUSE_MASK(bp);
  94. /* RX COS1 */
  95. pfc_params.llfc_high_priority_classes = 0;
  96. bnx2x_acquire_phy_lock(bp);
  97. bp->link_params.feature_config_flags |= FEATURE_CONFIG_PFC_ENABLED;
  98. bnx2x_update_pfc(&bp->link_params, &bp->link_vars, &pfc_params);
  99. bnx2x_release_phy_lock(bp);
  100. }
  101. static void bnx2x_pfc_clear(struct bnx2x *bp)
  102. {
  103. struct bnx2x_nig_brb_pfc_port_params nig_params = {0};
  104. nig_params.pause_enable = 1;
  105. bnx2x_acquire_phy_lock(bp);
  106. bp->link_params.feature_config_flags &= ~FEATURE_CONFIG_PFC_ENABLED;
  107. bnx2x_update_pfc(&bp->link_params, &bp->link_vars, &nig_params);
  108. bnx2x_release_phy_lock(bp);
  109. }
  110. static void bnx2x_dump_dcbx_drv_param(struct bnx2x *bp,
  111. struct dcbx_features *features,
  112. u32 error)
  113. {
  114. u8 i = 0;
  115. DP(NETIF_MSG_LINK, "local_mib.error %x\n", error);
  116. /* PG */
  117. DP(NETIF_MSG_LINK,
  118. "local_mib.features.ets.enabled %x\n", features->ets.enabled);
  119. for (i = 0; i < DCBX_MAX_NUM_PG_BW_ENTRIES; i++)
  120. DP(NETIF_MSG_LINK,
  121. "local_mib.features.ets.pg_bw_tbl[%d] %d\n", i,
  122. DCBX_PG_BW_GET(features->ets.pg_bw_tbl, i));
  123. for (i = 0; i < DCBX_MAX_NUM_PRI_PG_ENTRIES; i++)
  124. DP(NETIF_MSG_LINK,
  125. "local_mib.features.ets.pri_pg_tbl[%d] %d\n", i,
  126. DCBX_PRI_PG_GET(features->ets.pri_pg_tbl, i));
  127. /* pfc */
  128. DP(BNX2X_MSG_DCB, "dcbx_features.pfc.pri_en_bitmap %x\n",
  129. features->pfc.pri_en_bitmap);
  130. DP(BNX2X_MSG_DCB, "dcbx_features.pfc.pfc_caps %x\n",
  131. features->pfc.pfc_caps);
  132. DP(BNX2X_MSG_DCB, "dcbx_features.pfc.enabled %x\n",
  133. features->pfc.enabled);
  134. DP(BNX2X_MSG_DCB, "dcbx_features.app.default_pri %x\n",
  135. features->app.default_pri);
  136. DP(BNX2X_MSG_DCB, "dcbx_features.app.tc_supported %x\n",
  137. features->app.tc_supported);
  138. DP(BNX2X_MSG_DCB, "dcbx_features.app.enabled %x\n",
  139. features->app.enabled);
  140. for (i = 0; i < DCBX_MAX_APP_PROTOCOL; i++) {
  141. DP(BNX2X_MSG_DCB,
  142. "dcbx_features.app.app_pri_tbl[%x].app_id %x\n",
  143. i, features->app.app_pri_tbl[i].app_id);
  144. DP(BNX2X_MSG_DCB,
  145. "dcbx_features.app.app_pri_tbl[%x].pri_bitmap %x\n",
  146. i, features->app.app_pri_tbl[i].pri_bitmap);
  147. DP(BNX2X_MSG_DCB,
  148. "dcbx_features.app.app_pri_tbl[%x].appBitfield %x\n",
  149. i, features->app.app_pri_tbl[i].appBitfield);
  150. }
  151. }
  152. static void bnx2x_dcbx_get_ap_priority(struct bnx2x *bp,
  153. u8 pri_bitmap,
  154. u8 llfc_traf_type)
  155. {
  156. u32 pri = MAX_PFC_PRIORITIES;
  157. u32 index = MAX_PFC_PRIORITIES - 1;
  158. u32 pri_mask;
  159. u32 *ttp = bp->dcbx_port_params.app.traffic_type_priority;
  160. /* Choose the highest priority */
  161. while ((MAX_PFC_PRIORITIES == pri) && (0 != index)) {
  162. pri_mask = 1 << index;
  163. if (GET_FLAGS(pri_bitmap, pri_mask))
  164. pri = index ;
  165. index--;
  166. }
  167. if (pri < MAX_PFC_PRIORITIES)
  168. ttp[llfc_traf_type] = max_t(u32, ttp[llfc_traf_type], pri);
  169. }
  170. static void bnx2x_dcbx_get_ap_feature(struct bnx2x *bp,
  171. struct dcbx_app_priority_feature *app,
  172. u32 error) {
  173. u8 index;
  174. u32 *ttp = bp->dcbx_port_params.app.traffic_type_priority;
  175. if (GET_FLAGS(error, DCBX_LOCAL_APP_ERROR))
  176. DP(BNX2X_MSG_DCB, "DCBX_LOCAL_APP_ERROR\n");
  177. if (GET_FLAGS(error, DCBX_LOCAL_APP_MISMATCH))
  178. DP(BNX2X_MSG_DCB, "DCBX_LOCAL_APP_MISMATCH\n");
  179. if (GET_FLAGS(error, DCBX_REMOTE_APP_TLV_NOT_FOUND))
  180. DP(BNX2X_MSG_DCB, "DCBX_REMOTE_APP_TLV_NOT_FOUND\n");
  181. if (app->enabled &&
  182. !GET_FLAGS(error, DCBX_LOCAL_APP_ERROR | DCBX_LOCAL_APP_MISMATCH |
  183. DCBX_REMOTE_APP_TLV_NOT_FOUND)) {
  184. bp->dcbx_port_params.app.enabled = true;
  185. for (index = 0 ; index < LLFC_DRIVER_TRAFFIC_TYPE_MAX; index++)
  186. ttp[index] = 0;
  187. if (app->default_pri < MAX_PFC_PRIORITIES)
  188. ttp[LLFC_TRAFFIC_TYPE_NW] = app->default_pri;
  189. for (index = 0 ; index < DCBX_MAX_APP_PROTOCOL; index++) {
  190. struct dcbx_app_priority_entry *entry =
  191. app->app_pri_tbl;
  192. if (GET_FLAGS(entry[index].appBitfield,
  193. DCBX_APP_SF_ETH_TYPE) &&
  194. ETH_TYPE_FCOE == entry[index].app_id)
  195. bnx2x_dcbx_get_ap_priority(bp,
  196. entry[index].pri_bitmap,
  197. LLFC_TRAFFIC_TYPE_FCOE);
  198. if (GET_FLAGS(entry[index].appBitfield,
  199. DCBX_APP_SF_PORT) &&
  200. TCP_PORT_ISCSI == entry[index].app_id)
  201. bnx2x_dcbx_get_ap_priority(bp,
  202. entry[index].pri_bitmap,
  203. LLFC_TRAFFIC_TYPE_ISCSI);
  204. }
  205. } else {
  206. DP(BNX2X_MSG_DCB, "DCBX_LOCAL_APP_DISABLED\n");
  207. bp->dcbx_port_params.app.enabled = false;
  208. for (index = 0 ; index < LLFC_DRIVER_TRAFFIC_TYPE_MAX; index++)
  209. ttp[index] = INVALID_TRAFFIC_TYPE_PRIORITY;
  210. }
  211. }
  212. static void bnx2x_dcbx_get_ets_feature(struct bnx2x *bp,
  213. struct dcbx_ets_feature *ets,
  214. u32 error) {
  215. int i = 0;
  216. u32 pg_pri_orginal_spread[DCBX_MAX_NUM_PG_BW_ENTRIES] = {0};
  217. struct pg_help_data pg_help_data;
  218. struct bnx2x_dcbx_cos_params *cos_params =
  219. bp->dcbx_port_params.ets.cos_params;
  220. memset(&pg_help_data, 0, sizeof(struct pg_help_data));
  221. if (GET_FLAGS(error, DCBX_LOCAL_ETS_ERROR))
  222. DP(BNX2X_MSG_DCB, "DCBX_LOCAL_ETS_ERROR\n");
  223. if (GET_FLAGS(error, DCBX_REMOTE_ETS_TLV_NOT_FOUND))
  224. DP(BNX2X_MSG_DCB, "DCBX_REMOTE_ETS_TLV_NOT_FOUND\n");
  225. /* Clean up old settings of ets on COS */
  226. for (i = 0; i < ARRAY_SIZE(bp->dcbx_port_params.ets.cos_params) ; i++) {
  227. cos_params[i].pauseable = false;
  228. cos_params[i].strict = BNX2X_DCBX_STRICT_INVALID;
  229. cos_params[i].bw_tbl = DCBX_INVALID_COS_BW;
  230. cos_params[i].pri_bitmask = 0;
  231. }
  232. if (bp->dcbx_port_params.app.enabled && ets->enabled &&
  233. !GET_FLAGS(error,
  234. DCBX_LOCAL_ETS_ERROR | DCBX_REMOTE_ETS_TLV_NOT_FOUND)) {
  235. DP(BNX2X_MSG_DCB, "DCBX_LOCAL_ETS_ENABLE\n");
  236. bp->dcbx_port_params.ets.enabled = true;
  237. bnx2x_dcbx_get_ets_pri_pg_tbl(bp,
  238. pg_pri_orginal_spread,
  239. ets->pri_pg_tbl);
  240. bnx2x_dcbx_get_num_pg_traf_type(bp,
  241. pg_pri_orginal_spread,
  242. &pg_help_data);
  243. bnx2x_dcbx_fill_cos_params(bp, &pg_help_data,
  244. ets, pg_pri_orginal_spread);
  245. } else {
  246. DP(BNX2X_MSG_DCB, "DCBX_LOCAL_ETS_DISABLED\n");
  247. bp->dcbx_port_params.ets.enabled = false;
  248. ets->pri_pg_tbl[0] = 0;
  249. for (i = 0; i < DCBX_MAX_NUM_PRI_PG_ENTRIES ; i++)
  250. DCBX_PG_BW_SET(ets->pg_bw_tbl, i, 1);
  251. }
  252. }
  253. static void bnx2x_dcbx_get_pfc_feature(struct bnx2x *bp,
  254. struct dcbx_pfc_feature *pfc, u32 error)
  255. {
  256. if (GET_FLAGS(error, DCBX_LOCAL_PFC_ERROR))
  257. DP(BNX2X_MSG_DCB, "DCBX_LOCAL_PFC_ERROR\n");
  258. if (GET_FLAGS(error, DCBX_REMOTE_PFC_TLV_NOT_FOUND))
  259. DP(BNX2X_MSG_DCB, "DCBX_REMOTE_PFC_TLV_NOT_FOUND\n");
  260. if (bp->dcbx_port_params.app.enabled && pfc->enabled &&
  261. !GET_FLAGS(error, DCBX_LOCAL_PFC_ERROR | DCBX_LOCAL_PFC_MISMATCH |
  262. DCBX_REMOTE_PFC_TLV_NOT_FOUND)) {
  263. bp->dcbx_port_params.pfc.enabled = true;
  264. bp->dcbx_port_params.pfc.priority_non_pauseable_mask =
  265. ~(pfc->pri_en_bitmap);
  266. } else {
  267. DP(BNX2X_MSG_DCB, "DCBX_LOCAL_PFC_DISABLED\n");
  268. bp->dcbx_port_params.pfc.enabled = false;
  269. bp->dcbx_port_params.pfc.priority_non_pauseable_mask = 0;
  270. }
  271. }
  272. /* maps unmapped priorities to to the same COS as L2 */
  273. static void bnx2x_dcbx_map_nw(struct bnx2x *bp)
  274. {
  275. int i;
  276. u32 unmapped = (1 << MAX_PFC_PRIORITIES) - 1; /* all ones */
  277. u32 *ttp = bp->dcbx_port_params.app.traffic_type_priority;
  278. u32 nw_prio = 1 << ttp[LLFC_TRAFFIC_TYPE_NW];
  279. struct bnx2x_dcbx_cos_params *cos_params =
  280. bp->dcbx_port_params.ets.cos_params;
  281. /* get unmapped priorities by clearing mapped bits */
  282. for (i = 0; i < LLFC_DRIVER_TRAFFIC_TYPE_MAX; i++)
  283. unmapped &= ~(1 << ttp[i]);
  284. /* find cos for nw prio and extend it with unmapped */
  285. for (i = 0; i < ARRAY_SIZE(bp->dcbx_port_params.ets.cos_params); i++) {
  286. if (cos_params[i].pri_bitmask & nw_prio) {
  287. /* extend the bitmask with unmapped */
  288. DP(BNX2X_MSG_DCB,
  289. "cos %d extended with 0x%08x\n", i, unmapped);
  290. cos_params[i].pri_bitmask |= unmapped;
  291. break;
  292. }
  293. }
  294. }
  295. static void bnx2x_get_dcbx_drv_param(struct bnx2x *bp,
  296. struct dcbx_features *features,
  297. u32 error)
  298. {
  299. bnx2x_dcbx_get_ap_feature(bp, &features->app, error);
  300. bnx2x_dcbx_get_pfc_feature(bp, &features->pfc, error);
  301. bnx2x_dcbx_get_ets_feature(bp, &features->ets, error);
  302. bnx2x_dcbx_map_nw(bp);
  303. }
  304. #define DCBX_LOCAL_MIB_MAX_TRY_READ (100)
  305. static int bnx2x_dcbx_read_mib(struct bnx2x *bp,
  306. u32 *base_mib_addr,
  307. u32 offset,
  308. int read_mib_type)
  309. {
  310. int max_try_read = 0;
  311. u32 mib_size, prefix_seq_num, suffix_seq_num;
  312. struct lldp_remote_mib *remote_mib ;
  313. struct lldp_local_mib *local_mib;
  314. switch (read_mib_type) {
  315. case DCBX_READ_LOCAL_MIB:
  316. mib_size = sizeof(struct lldp_local_mib);
  317. break;
  318. case DCBX_READ_REMOTE_MIB:
  319. mib_size = sizeof(struct lldp_remote_mib);
  320. break;
  321. default:
  322. return 1; /*error*/
  323. }
  324. offset += BP_PORT(bp) * mib_size;
  325. do {
  326. bnx2x_read_data(bp, base_mib_addr, offset, mib_size);
  327. max_try_read++;
  328. switch (read_mib_type) {
  329. case DCBX_READ_LOCAL_MIB:
  330. local_mib = (struct lldp_local_mib *) base_mib_addr;
  331. prefix_seq_num = local_mib->prefix_seq_num;
  332. suffix_seq_num = local_mib->suffix_seq_num;
  333. break;
  334. case DCBX_READ_REMOTE_MIB:
  335. remote_mib = (struct lldp_remote_mib *) base_mib_addr;
  336. prefix_seq_num = remote_mib->prefix_seq_num;
  337. suffix_seq_num = remote_mib->suffix_seq_num;
  338. break;
  339. default:
  340. return 1; /*error*/
  341. }
  342. } while ((prefix_seq_num != suffix_seq_num) &&
  343. (max_try_read < DCBX_LOCAL_MIB_MAX_TRY_READ));
  344. if (max_try_read >= DCBX_LOCAL_MIB_MAX_TRY_READ) {
  345. BNX2X_ERR("MIB could not be read\n");
  346. return 1;
  347. }
  348. return 0;
  349. }
  350. static void bnx2x_pfc_set_pfc(struct bnx2x *bp)
  351. {
  352. if (bp->dcbx_port_params.pfc.enabled &&
  353. !(bp->dcbx_error & DCBX_REMOTE_MIB_ERROR))
  354. /*
  355. * 1. Fills up common PFC structures if required
  356. * 2. Configure NIG, MAC and BRB via the elink
  357. */
  358. bnx2x_pfc_set(bp);
  359. else
  360. bnx2x_pfc_clear(bp);
  361. }
  362. static int bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp)
  363. {
  364. struct bnx2x_func_state_params func_params = {NULL};
  365. func_params.f_obj = &bp->func_obj;
  366. func_params.cmd = BNX2X_F_CMD_TX_STOP;
  367. DP(BNX2X_MSG_DCB, "STOP TRAFFIC\n");
  368. return bnx2x_func_state_change(bp, &func_params);
  369. }
  370. static int bnx2x_dcbx_resume_hw_tx(struct bnx2x *bp)
  371. {
  372. struct bnx2x_func_state_params func_params = {NULL};
  373. struct bnx2x_func_tx_start_params *tx_params =
  374. &func_params.params.tx_start;
  375. func_params.f_obj = &bp->func_obj;
  376. func_params.cmd = BNX2X_F_CMD_TX_START;
  377. bnx2x_dcbx_fw_struct(bp, tx_params);
  378. DP(BNX2X_MSG_DCB, "START TRAFFIC\n");
  379. return bnx2x_func_state_change(bp, &func_params);
  380. }
  381. static void bnx2x_dcbx_2cos_limit_update_ets_config(struct bnx2x *bp)
  382. {
  383. struct bnx2x_dcbx_pg_params *ets = &(bp->dcbx_port_params.ets);
  384. int rc = 0;
  385. if (ets->num_of_cos == 0 || ets->num_of_cos > DCBX_COS_MAX_NUM_E2) {
  386. BNX2X_ERR("Illegal number of COSes %d\n", ets->num_of_cos);
  387. return;
  388. }
  389. /* valid COS entries */
  390. if (ets->num_of_cos == 1) /* no ETS */
  391. return;
  392. /* sanity */
  393. if (((BNX2X_DCBX_STRICT_INVALID == ets->cos_params[0].strict) &&
  394. (DCBX_INVALID_COS_BW == ets->cos_params[0].bw_tbl)) ||
  395. ((BNX2X_DCBX_STRICT_INVALID == ets->cos_params[1].strict) &&
  396. (DCBX_INVALID_COS_BW == ets->cos_params[1].bw_tbl))) {
  397. BNX2X_ERR("all COS should have at least bw_limit or strict"
  398. "ets->cos_params[0].strict= %x"
  399. "ets->cos_params[0].bw_tbl= %x"
  400. "ets->cos_params[1].strict= %x"
  401. "ets->cos_params[1].bw_tbl= %x",
  402. ets->cos_params[0].strict,
  403. ets->cos_params[0].bw_tbl,
  404. ets->cos_params[1].strict,
  405. ets->cos_params[1].bw_tbl);
  406. return;
  407. }
  408. /* If we join a group and there is bw_tbl and strict then bw rules */
  409. if ((DCBX_INVALID_COS_BW != ets->cos_params[0].bw_tbl) &&
  410. (DCBX_INVALID_COS_BW != ets->cos_params[1].bw_tbl)) {
  411. u32 bw_tbl_0 = ets->cos_params[0].bw_tbl;
  412. u32 bw_tbl_1 = ets->cos_params[1].bw_tbl;
  413. /* Do not allow 0-100 configuration
  414. * since PBF does not support it
  415. * force 1-99 instead
  416. */
  417. if (bw_tbl_0 == 0) {
  418. bw_tbl_0 = 1;
  419. bw_tbl_1 = 99;
  420. } else if (bw_tbl_1 == 0) {
  421. bw_tbl_1 = 1;
  422. bw_tbl_0 = 99;
  423. }
  424. bnx2x_ets_bw_limit(&bp->link_params, bw_tbl_0, bw_tbl_1);
  425. } else {
  426. if (ets->cos_params[0].strict == BNX2X_DCBX_STRICT_COS_HIGHEST)
  427. rc = bnx2x_ets_strict(&bp->link_params, 0);
  428. else if (ets->cos_params[1].strict
  429. == BNX2X_DCBX_STRICT_COS_HIGHEST)
  430. rc = bnx2x_ets_strict(&bp->link_params, 1);
  431. if (rc)
  432. BNX2X_ERR("update_ets_params failed\n");
  433. }
  434. }
  435. /*
  436. * In E3B0 the configuration may have more than 2 COS.
  437. */
  438. static void bnx2x_dcbx_update_ets_config(struct bnx2x *bp)
  439. {
  440. struct bnx2x_dcbx_pg_params *ets = &(bp->dcbx_port_params.ets);
  441. struct bnx2x_ets_params ets_params = { 0 };
  442. u8 i;
  443. ets_params.num_of_cos = ets->num_of_cos;
  444. for (i = 0; i < ets->num_of_cos; i++) {
  445. /* COS is SP */
  446. if (ets->cos_params[i].strict != BNX2X_DCBX_STRICT_INVALID) {
  447. if (ets->cos_params[i].bw_tbl != DCBX_INVALID_COS_BW) {
  448. BNX2X_ERR("COS can't be not BW and not SP\n");
  449. return;
  450. }
  451. ets_params.cos[i].state = bnx2x_cos_state_strict;
  452. ets_params.cos[i].params.sp_params.pri =
  453. ets->cos_params[i].strict;
  454. } else { /* COS is BW */
  455. if (ets->cos_params[i].bw_tbl == DCBX_INVALID_COS_BW) {
  456. BNX2X_ERR("COS can't be not BW and not SP\n");
  457. return;
  458. }
  459. ets_params.cos[i].state = bnx2x_cos_state_bw;
  460. ets_params.cos[i].params.bw_params.bw =
  461. (u8)ets->cos_params[i].bw_tbl;
  462. }
  463. }
  464. /* Configure the ETS in HW */
  465. if (bnx2x_ets_e3b0_config(&bp->link_params, &bp->link_vars,
  466. &ets_params)) {
  467. BNX2X_ERR("bnx2x_ets_e3b0_config failed\n");
  468. bnx2x_ets_disabled(&bp->link_params, &bp->link_vars);
  469. }
  470. }
  471. static void bnx2x_dcbx_update_ets_params(struct bnx2x *bp)
  472. {
  473. bnx2x_ets_disabled(&bp->link_params, &bp->link_vars);
  474. if (!bp->dcbx_port_params.ets.enabled ||
  475. (bp->dcbx_error & DCBX_REMOTE_MIB_ERROR))
  476. return;
  477. if (CHIP_IS_E3B0(bp))
  478. bnx2x_dcbx_update_ets_config(bp);
  479. else
  480. bnx2x_dcbx_2cos_limit_update_ets_config(bp);
  481. }
  482. #ifdef BCM_DCBNL
  483. static int bnx2x_dcbx_read_shmem_remote_mib(struct bnx2x *bp)
  484. {
  485. struct lldp_remote_mib remote_mib = {0};
  486. u32 dcbx_remote_mib_offset = SHMEM2_RD(bp, dcbx_remote_mib_offset);
  487. int rc;
  488. DP(BNX2X_MSG_DCB, "dcbx_remote_mib_offset 0x%x\n",
  489. dcbx_remote_mib_offset);
  490. if (SHMEM_DCBX_REMOTE_MIB_NONE == dcbx_remote_mib_offset) {
  491. BNX2X_ERR("FW doesn't support dcbx_remote_mib_offset\n");
  492. return -EINVAL;
  493. }
  494. rc = bnx2x_dcbx_read_mib(bp, (u32 *)&remote_mib, dcbx_remote_mib_offset,
  495. DCBX_READ_REMOTE_MIB);
  496. if (rc) {
  497. BNX2X_ERR("Faild to read remote mib from FW\n");
  498. return rc;
  499. }
  500. /* save features and flags */
  501. bp->dcbx_remote_feat = remote_mib.features;
  502. bp->dcbx_remote_flags = remote_mib.flags;
  503. return 0;
  504. }
  505. #endif
  506. static int bnx2x_dcbx_read_shmem_neg_results(struct bnx2x *bp)
  507. {
  508. struct lldp_local_mib local_mib = {0};
  509. u32 dcbx_neg_res_offset = SHMEM2_RD(bp, dcbx_neg_res_offset);
  510. int rc;
  511. DP(BNX2X_MSG_DCB, "dcbx_neg_res_offset 0x%x\n", dcbx_neg_res_offset);
  512. if (SHMEM_DCBX_NEG_RES_NONE == dcbx_neg_res_offset) {
  513. BNX2X_ERR("FW doesn't support dcbx_neg_res_offset\n");
  514. return -EINVAL;
  515. }
  516. rc = bnx2x_dcbx_read_mib(bp, (u32 *)&local_mib, dcbx_neg_res_offset,
  517. DCBX_READ_LOCAL_MIB);
  518. if (rc) {
  519. BNX2X_ERR("Faild to read local mib from FW\n");
  520. return rc;
  521. }
  522. /* save features and error */
  523. bp->dcbx_local_feat = local_mib.features;
  524. bp->dcbx_error = local_mib.error;
  525. return 0;
  526. }
  527. #ifdef BCM_DCBNL
  528. static inline
  529. u8 bnx2x_dcbx_dcbnl_app_up(struct dcbx_app_priority_entry *ent)
  530. {
  531. u8 pri;
  532. /* Choose the highest priority */
  533. for (pri = MAX_PFC_PRIORITIES - 1; pri > 0; pri--)
  534. if (ent->pri_bitmap & (1 << pri))
  535. break;
  536. return pri;
  537. }
  538. static inline
  539. u8 bnx2x_dcbx_dcbnl_app_idtype(struct dcbx_app_priority_entry *ent)
  540. {
  541. return ((ent->appBitfield & DCBX_APP_ENTRY_SF_MASK) ==
  542. DCBX_APP_SF_PORT) ? DCB_APP_IDTYPE_PORTNUM :
  543. DCB_APP_IDTYPE_ETHTYPE;
  544. }
  545. int bnx2x_dcbnl_update_applist(struct bnx2x *bp, bool delall)
  546. {
  547. int i, err = 0;
  548. for (i = 0; i < DCBX_MAX_APP_PROTOCOL && err == 0; i++) {
  549. struct dcbx_app_priority_entry *ent =
  550. &bp->dcbx_local_feat.app.app_pri_tbl[i];
  551. if (ent->appBitfield & DCBX_APP_ENTRY_VALID) {
  552. u8 up = bnx2x_dcbx_dcbnl_app_up(ent);
  553. /* avoid invalid user-priority */
  554. if (up) {
  555. struct dcb_app app;
  556. app.selector = bnx2x_dcbx_dcbnl_app_idtype(ent);
  557. app.protocol = ent->app_id;
  558. app.priority = delall ? 0 : up;
  559. err = dcb_setapp(bp->dev, &app);
  560. }
  561. }
  562. }
  563. return err;
  564. }
  565. #endif
  566. static inline void bnx2x_dcbx_update_tc_mapping(struct bnx2x *bp)
  567. {
  568. u8 prio, cos;
  569. for (cos = 0; cos < bp->dcbx_port_params.ets.num_of_cos; cos++) {
  570. for (prio = 0; prio < BNX2X_MAX_PRIORITY; prio++) {
  571. if (bp->dcbx_port_params.ets.cos_params[cos].pri_bitmask
  572. & (1 << prio)) {
  573. bp->prio_to_cos[prio] = cos;
  574. DP(BNX2X_MSG_DCB,
  575. "tx_mapping %d --> %d\n", prio, cos);
  576. }
  577. }
  578. }
  579. /* setup tc must be called under rtnl lock, but we can't take it here
  580. * as we are handling an attetntion on a work queue which must be
  581. * flushed at some rtnl-locked contexts (e.g. if down)
  582. */
  583. if (!test_and_set_bit(BNX2X_SP_RTNL_SETUP_TC, &bp->sp_rtnl_state))
  584. schedule_delayed_work(&bp->sp_rtnl_task, 0);
  585. }
  586. void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state)
  587. {
  588. switch (state) {
  589. case BNX2X_DCBX_STATE_NEG_RECEIVED:
  590. {
  591. DP(BNX2X_MSG_DCB, "BNX2X_DCBX_STATE_NEG_RECEIVED\n");
  592. #ifdef BCM_DCBNL
  593. /**
  594. * Delete app tlvs from dcbnl before reading new
  595. * negotiation results
  596. */
  597. bnx2x_dcbnl_update_applist(bp, true);
  598. /* Read rmeote mib if dcbx is in the FW */
  599. if (bnx2x_dcbx_read_shmem_remote_mib(bp))
  600. return;
  601. #endif
  602. /* Read neg results if dcbx is in the FW */
  603. if (bnx2x_dcbx_read_shmem_neg_results(bp))
  604. return;
  605. bnx2x_dump_dcbx_drv_param(bp, &bp->dcbx_local_feat,
  606. bp->dcbx_error);
  607. bnx2x_get_dcbx_drv_param(bp, &bp->dcbx_local_feat,
  608. bp->dcbx_error);
  609. /* mark DCBX result for PMF migration */
  610. bnx2x_update_drv_flags(bp,
  611. 1 << DRV_FLAGS_DCB_CONFIGURED,
  612. 1);
  613. #ifdef BCM_DCBNL
  614. /*
  615. * Add new app tlvs to dcbnl
  616. */
  617. bnx2x_dcbnl_update_applist(bp, false);
  618. #endif
  619. /*
  620. * reconfigure the netdevice with the results of the new
  621. * dcbx negotiation.
  622. */
  623. bnx2x_dcbx_update_tc_mapping(bp);
  624. /*
  625. * allow other funtions to update their netdevices
  626. * accordingly
  627. */
  628. if (IS_MF(bp))
  629. bnx2x_link_sync_notify(bp);
  630. bnx2x_dcbx_stop_hw_tx(bp);
  631. return;
  632. }
  633. case BNX2X_DCBX_STATE_TX_PAUSED:
  634. DP(BNX2X_MSG_DCB, "BNX2X_DCBX_STATE_TX_PAUSED\n");
  635. bnx2x_pfc_set_pfc(bp);
  636. bnx2x_dcbx_update_ets_params(bp);
  637. bnx2x_dcbx_resume_hw_tx(bp);
  638. return;
  639. case BNX2X_DCBX_STATE_TX_RELEASED:
  640. DP(BNX2X_MSG_DCB, "BNX2X_DCBX_STATE_TX_RELEASED\n");
  641. bnx2x_fw_command(bp, DRV_MSG_CODE_DCBX_PMF_DRV_OK, 0);
  642. #ifdef BCM_DCBNL
  643. /*
  644. * Send a notification for the new negotiated parameters
  645. */
  646. dcbnl_cee_notify(bp->dev, RTM_GETDCB, DCB_CMD_CEE_GET, 0, 0);
  647. #endif
  648. return;
  649. default:
  650. BNX2X_ERR("Unknown DCBX_STATE\n");
  651. }
  652. }
  653. #define LLDP_ADMIN_MIB_OFFSET(bp) (PORT_MAX*sizeof(struct lldp_params) + \
  654. BP_PORT(bp)*sizeof(struct lldp_admin_mib))
  655. static void bnx2x_dcbx_admin_mib_updated_params(struct bnx2x *bp,
  656. u32 dcbx_lldp_params_offset)
  657. {
  658. struct lldp_admin_mib admin_mib;
  659. u32 i, other_traf_type = PREDEFINED_APP_IDX_MAX, traf_type = 0;
  660. u32 offset = dcbx_lldp_params_offset + LLDP_ADMIN_MIB_OFFSET(bp);
  661. /*shortcuts*/
  662. struct dcbx_features *af = &admin_mib.features;
  663. struct bnx2x_config_dcbx_params *dp = &bp->dcbx_config_params;
  664. memset(&admin_mib, 0, sizeof(struct lldp_admin_mib));
  665. /* Read the data first */
  666. bnx2x_read_data(bp, (u32 *)&admin_mib, offset,
  667. sizeof(struct lldp_admin_mib));
  668. if (bp->dcbx_enabled == BNX2X_DCBX_ENABLED_ON_NEG_ON)
  669. SET_FLAGS(admin_mib.ver_cfg_flags, DCBX_DCBX_ENABLED);
  670. else
  671. RESET_FLAGS(admin_mib.ver_cfg_flags, DCBX_DCBX_ENABLED);
  672. if (dp->overwrite_settings == BNX2X_DCBX_OVERWRITE_SETTINGS_ENABLE) {
  673. RESET_FLAGS(admin_mib.ver_cfg_flags, DCBX_CEE_VERSION_MASK);
  674. admin_mib.ver_cfg_flags |=
  675. (dp->admin_dcbx_version << DCBX_CEE_VERSION_SHIFT) &
  676. DCBX_CEE_VERSION_MASK;
  677. af->ets.enabled = (u8)dp->admin_ets_enable;
  678. af->pfc.enabled = (u8)dp->admin_pfc_enable;
  679. /* FOR IEEE dp->admin_tc_supported_tx_enable */
  680. if (dp->admin_ets_configuration_tx_enable)
  681. SET_FLAGS(admin_mib.ver_cfg_flags,
  682. DCBX_ETS_CONFIG_TX_ENABLED);
  683. else
  684. RESET_FLAGS(admin_mib.ver_cfg_flags,
  685. DCBX_ETS_CONFIG_TX_ENABLED);
  686. /* For IEEE admin_ets_recommendation_tx_enable */
  687. if (dp->admin_pfc_tx_enable)
  688. SET_FLAGS(admin_mib.ver_cfg_flags,
  689. DCBX_PFC_CONFIG_TX_ENABLED);
  690. else
  691. RESET_FLAGS(admin_mib.ver_cfg_flags,
  692. DCBX_PFC_CONFIG_TX_ENABLED);
  693. if (dp->admin_application_priority_tx_enable)
  694. SET_FLAGS(admin_mib.ver_cfg_flags,
  695. DCBX_APP_CONFIG_TX_ENABLED);
  696. else
  697. RESET_FLAGS(admin_mib.ver_cfg_flags,
  698. DCBX_APP_CONFIG_TX_ENABLED);
  699. if (dp->admin_ets_willing)
  700. SET_FLAGS(admin_mib.ver_cfg_flags, DCBX_ETS_WILLING);
  701. else
  702. RESET_FLAGS(admin_mib.ver_cfg_flags, DCBX_ETS_WILLING);
  703. /* For IEEE admin_ets_reco_valid */
  704. if (dp->admin_pfc_willing)
  705. SET_FLAGS(admin_mib.ver_cfg_flags, DCBX_PFC_WILLING);
  706. else
  707. RESET_FLAGS(admin_mib.ver_cfg_flags, DCBX_PFC_WILLING);
  708. if (dp->admin_app_priority_willing)
  709. SET_FLAGS(admin_mib.ver_cfg_flags, DCBX_APP_WILLING);
  710. else
  711. RESET_FLAGS(admin_mib.ver_cfg_flags, DCBX_APP_WILLING);
  712. for (i = 0 ; i < DCBX_MAX_NUM_PG_BW_ENTRIES; i++) {
  713. DCBX_PG_BW_SET(af->ets.pg_bw_tbl, i,
  714. (u8)dp->admin_configuration_bw_precentage[i]);
  715. DP(BNX2X_MSG_DCB, "pg_bw_tbl[%d] = %02x\n",
  716. i, DCBX_PG_BW_GET(af->ets.pg_bw_tbl, i));
  717. }
  718. for (i = 0; i < DCBX_MAX_NUM_PRI_PG_ENTRIES; i++) {
  719. DCBX_PRI_PG_SET(af->ets.pri_pg_tbl, i,
  720. (u8)dp->admin_configuration_ets_pg[i]);
  721. DP(BNX2X_MSG_DCB, "pri_pg_tbl[%d] = %02x\n",
  722. i, DCBX_PRI_PG_GET(af->ets.pri_pg_tbl, i));
  723. }
  724. /*For IEEE admin_recommendation_bw_precentage
  725. *For IEEE admin_recommendation_ets_pg */
  726. af->pfc.pri_en_bitmap = (u8)dp->admin_pfc_bitmap;
  727. for (i = 0; i < DCBX_CONFIG_MAX_APP_PROTOCOL; i++) {
  728. if (dp->admin_priority_app_table[i].valid) {
  729. struct bnx2x_admin_priority_app_table *table =
  730. dp->admin_priority_app_table;
  731. if ((ETH_TYPE_FCOE == table[i].app_id) &&
  732. (TRAFFIC_TYPE_ETH == table[i].traffic_type))
  733. traf_type = FCOE_APP_IDX;
  734. else if ((TCP_PORT_ISCSI == table[i].app_id) &&
  735. (TRAFFIC_TYPE_PORT == table[i].traffic_type))
  736. traf_type = ISCSI_APP_IDX;
  737. else
  738. traf_type = other_traf_type++;
  739. af->app.app_pri_tbl[traf_type].app_id =
  740. table[i].app_id;
  741. af->app.app_pri_tbl[traf_type].pri_bitmap =
  742. (u8)(1 << table[i].priority);
  743. af->app.app_pri_tbl[traf_type].appBitfield =
  744. (DCBX_APP_ENTRY_VALID);
  745. af->app.app_pri_tbl[traf_type].appBitfield |=
  746. (TRAFFIC_TYPE_ETH == table[i].traffic_type) ?
  747. DCBX_APP_SF_ETH_TYPE : DCBX_APP_SF_PORT;
  748. }
  749. }
  750. af->app.default_pri = (u8)dp->admin_default_priority;
  751. }
  752. /* Write the data. */
  753. bnx2x_write_data(bp, (u32 *)&admin_mib, offset,
  754. sizeof(struct lldp_admin_mib));
  755. }
  756. void bnx2x_dcbx_set_state(struct bnx2x *bp, bool dcb_on, u32 dcbx_enabled)
  757. {
  758. if (!CHIP_IS_E1x(bp)) {
  759. bp->dcb_state = dcb_on;
  760. bp->dcbx_enabled = dcbx_enabled;
  761. } else {
  762. bp->dcb_state = false;
  763. bp->dcbx_enabled = BNX2X_DCBX_ENABLED_INVALID;
  764. }
  765. DP(BNX2X_MSG_DCB, "DCB state [%s:%s]\n",
  766. dcb_on ? "ON" : "OFF",
  767. dcbx_enabled == BNX2X_DCBX_ENABLED_OFF ? "user-mode" :
  768. dcbx_enabled == BNX2X_DCBX_ENABLED_ON_NEG_OFF ? "on-chip static" :
  769. dcbx_enabled == BNX2X_DCBX_ENABLED_ON_NEG_ON ?
  770. "on-chip with negotiation" : "invalid");
  771. }
  772. void bnx2x_dcbx_init_params(struct bnx2x *bp)
  773. {
  774. bp->dcbx_config_params.admin_dcbx_version = 0x0; /* 0 - CEE; 1 - IEEE */
  775. bp->dcbx_config_params.admin_ets_willing = 1;
  776. bp->dcbx_config_params.admin_pfc_willing = 1;
  777. bp->dcbx_config_params.overwrite_settings = 1;
  778. bp->dcbx_config_params.admin_ets_enable = 1;
  779. bp->dcbx_config_params.admin_pfc_enable = 1;
  780. bp->dcbx_config_params.admin_tc_supported_tx_enable = 1;
  781. bp->dcbx_config_params.admin_ets_configuration_tx_enable = 1;
  782. bp->dcbx_config_params.admin_pfc_tx_enable = 1;
  783. bp->dcbx_config_params.admin_application_priority_tx_enable = 1;
  784. bp->dcbx_config_params.admin_ets_reco_valid = 1;
  785. bp->dcbx_config_params.admin_app_priority_willing = 1;
  786. bp->dcbx_config_params.admin_configuration_bw_precentage[0] = 100;
  787. bp->dcbx_config_params.admin_configuration_bw_precentage[1] = 0;
  788. bp->dcbx_config_params.admin_configuration_bw_precentage[2] = 0;
  789. bp->dcbx_config_params.admin_configuration_bw_precentage[3] = 0;
  790. bp->dcbx_config_params.admin_configuration_bw_precentage[4] = 0;
  791. bp->dcbx_config_params.admin_configuration_bw_precentage[5] = 0;
  792. bp->dcbx_config_params.admin_configuration_bw_precentage[6] = 0;
  793. bp->dcbx_config_params.admin_configuration_bw_precentage[7] = 0;
  794. bp->dcbx_config_params.admin_configuration_ets_pg[0] = 0;
  795. bp->dcbx_config_params.admin_configuration_ets_pg[1] = 0;
  796. bp->dcbx_config_params.admin_configuration_ets_pg[2] = 0;
  797. bp->dcbx_config_params.admin_configuration_ets_pg[3] = 0;
  798. bp->dcbx_config_params.admin_configuration_ets_pg[4] = 0;
  799. bp->dcbx_config_params.admin_configuration_ets_pg[5] = 0;
  800. bp->dcbx_config_params.admin_configuration_ets_pg[6] = 0;
  801. bp->dcbx_config_params.admin_configuration_ets_pg[7] = 0;
  802. bp->dcbx_config_params.admin_recommendation_bw_precentage[0] = 100;
  803. bp->dcbx_config_params.admin_recommendation_bw_precentage[1] = 0;
  804. bp->dcbx_config_params.admin_recommendation_bw_precentage[2] = 0;
  805. bp->dcbx_config_params.admin_recommendation_bw_precentage[3] = 0;
  806. bp->dcbx_config_params.admin_recommendation_bw_precentage[4] = 0;
  807. bp->dcbx_config_params.admin_recommendation_bw_precentage[5] = 0;
  808. bp->dcbx_config_params.admin_recommendation_bw_precentage[6] = 0;
  809. bp->dcbx_config_params.admin_recommendation_bw_precentage[7] = 0;
  810. bp->dcbx_config_params.admin_recommendation_ets_pg[0] = 0;
  811. bp->dcbx_config_params.admin_recommendation_ets_pg[1] = 1;
  812. bp->dcbx_config_params.admin_recommendation_ets_pg[2] = 2;
  813. bp->dcbx_config_params.admin_recommendation_ets_pg[3] = 3;
  814. bp->dcbx_config_params.admin_recommendation_ets_pg[4] = 4;
  815. bp->dcbx_config_params.admin_recommendation_ets_pg[5] = 5;
  816. bp->dcbx_config_params.admin_recommendation_ets_pg[6] = 6;
  817. bp->dcbx_config_params.admin_recommendation_ets_pg[7] = 7;
  818. bp->dcbx_config_params.admin_pfc_bitmap = 0x0;
  819. bp->dcbx_config_params.admin_priority_app_table[0].valid = 0;
  820. bp->dcbx_config_params.admin_priority_app_table[1].valid = 0;
  821. bp->dcbx_config_params.admin_priority_app_table[2].valid = 0;
  822. bp->dcbx_config_params.admin_priority_app_table[3].valid = 0;
  823. bp->dcbx_config_params.admin_default_priority = 0;
  824. }
  825. void bnx2x_dcbx_init(struct bnx2x *bp, bool update_shmem)
  826. {
  827. u32 dcbx_lldp_params_offset = SHMEM_LLDP_DCBX_PARAMS_NONE;
  828. /* only PMF can send ADMIN msg to MFW in old MFW versions */
  829. if ((!bp->port.pmf) && (!(bp->flags & BC_SUPPORTS_DCBX_MSG_NON_PMF)))
  830. return;
  831. if (bp->dcbx_enabled <= 0)
  832. return;
  833. /* validate:
  834. * chip of good for dcbx version,
  835. * dcb is wanted
  836. * shmem2 contains DCBX support fields
  837. */
  838. DP(BNX2X_MSG_DCB, "dcb_state %d bp->port.pmf %d\n",
  839. bp->dcb_state, bp->port.pmf);
  840. if (bp->dcb_state == BNX2X_DCB_STATE_ON &&
  841. SHMEM2_HAS(bp, dcbx_lldp_params_offset)) {
  842. dcbx_lldp_params_offset =
  843. SHMEM2_RD(bp, dcbx_lldp_params_offset);
  844. DP(BNX2X_MSG_DCB, "dcbx_lldp_params_offset 0x%x\n",
  845. dcbx_lldp_params_offset);
  846. bnx2x_update_drv_flags(bp, 1 << DRV_FLAGS_DCB_CONFIGURED, 0);
  847. if (SHMEM_LLDP_DCBX_PARAMS_NONE != dcbx_lldp_params_offset) {
  848. /* need HW lock to avoid scenario of two drivers
  849. * writing in parallel to shmem
  850. */
  851. bnx2x_acquire_hw_lock(bp,
  852. HW_LOCK_RESOURCE_DCBX_ADMIN_MIB);
  853. if (update_shmem)
  854. bnx2x_dcbx_admin_mib_updated_params(bp,
  855. dcbx_lldp_params_offset);
  856. /* Let HW start negotiation */
  857. bnx2x_fw_command(bp,
  858. DRV_MSG_CODE_DCBX_ADMIN_PMF_MSG, 0);
  859. /* release HW lock only after MFW acks that it finished
  860. * reading values from shmem
  861. */
  862. bnx2x_release_hw_lock(bp,
  863. HW_LOCK_RESOURCE_DCBX_ADMIN_MIB);
  864. }
  865. }
  866. }
  867. static void
  868. bnx2x_dcbx_print_cos_params(struct bnx2x *bp,
  869. struct bnx2x_func_tx_start_params *pfc_fw_cfg)
  870. {
  871. u8 pri = 0;
  872. u8 cos = 0;
  873. DP(BNX2X_MSG_DCB,
  874. "pfc_fw_cfg->dcb_version %x\n", pfc_fw_cfg->dcb_version);
  875. DP(BNX2X_MSG_DCB,
  876. "pdev->params.dcbx_port_params.pfc.priority_non_pauseable_mask %x\n",
  877. bp->dcbx_port_params.pfc.priority_non_pauseable_mask);
  878. for (cos = 0 ; cos < bp->dcbx_port_params.ets.num_of_cos ; cos++) {
  879. DP(BNX2X_MSG_DCB,
  880. "pdev->params.dcbx_port_params.ets.cos_params[%d].pri_bitmask %x\n",
  881. cos, bp->dcbx_port_params.ets.cos_params[cos].pri_bitmask);
  882. DP(BNX2X_MSG_DCB,
  883. "pdev->params.dcbx_port_params.ets.cos_params[%d].bw_tbl %x\n",
  884. cos, bp->dcbx_port_params.ets.cos_params[cos].bw_tbl);
  885. DP(BNX2X_MSG_DCB,
  886. "pdev->params.dcbx_port_params.ets.cos_params[%d].strict %x\n",
  887. cos, bp->dcbx_port_params.ets.cos_params[cos].strict);
  888. DP(BNX2X_MSG_DCB,
  889. "pdev->params.dcbx_port_params.ets.cos_params[%d].pauseable %x\n",
  890. cos, bp->dcbx_port_params.ets.cos_params[cos].pauseable);
  891. }
  892. for (pri = 0; pri < LLFC_DRIVER_TRAFFIC_TYPE_MAX; pri++) {
  893. DP(BNX2X_MSG_DCB,
  894. "pfc_fw_cfg->traffic_type_to_priority_cos[%d].priority %x\n",
  895. pri, pfc_fw_cfg->traffic_type_to_priority_cos[pri].priority);
  896. DP(BNX2X_MSG_DCB,
  897. "pfc_fw_cfg->traffic_type_to_priority_cos[%d].cos %x\n",
  898. pri, pfc_fw_cfg->traffic_type_to_priority_cos[pri].cos);
  899. }
  900. }
  901. /* fills help_data according to pg_info */
  902. static void bnx2x_dcbx_get_num_pg_traf_type(struct bnx2x *bp,
  903. u32 *pg_pri_orginal_spread,
  904. struct pg_help_data *help_data)
  905. {
  906. bool pg_found = false;
  907. u32 i, traf_type, add_traf_type, add_pg;
  908. u32 *ttp = bp->dcbx_port_params.app.traffic_type_priority;
  909. struct pg_entry_help_data *data = help_data->data; /*shotcut*/
  910. /* Set to invalid */
  911. for (i = 0; i < LLFC_DRIVER_TRAFFIC_TYPE_MAX; i++)
  912. data[i].pg = DCBX_ILLEGAL_PG;
  913. for (add_traf_type = 0;
  914. add_traf_type < LLFC_DRIVER_TRAFFIC_TYPE_MAX; add_traf_type++) {
  915. pg_found = false;
  916. if (ttp[add_traf_type] < MAX_PFC_PRIORITIES) {
  917. add_pg = (u8)pg_pri_orginal_spread[ttp[add_traf_type]];
  918. for (traf_type = 0;
  919. traf_type < LLFC_DRIVER_TRAFFIC_TYPE_MAX;
  920. traf_type++) {
  921. if (data[traf_type].pg == add_pg) {
  922. if (!(data[traf_type].pg_priority &
  923. (1 << ttp[add_traf_type])))
  924. data[traf_type].
  925. num_of_dif_pri++;
  926. data[traf_type].pg_priority |=
  927. (1 << ttp[add_traf_type]);
  928. pg_found = true;
  929. break;
  930. }
  931. }
  932. if (false == pg_found) {
  933. data[help_data->num_of_pg].pg = add_pg;
  934. data[help_data->num_of_pg].pg_priority =
  935. (1 << ttp[add_traf_type]);
  936. data[help_data->num_of_pg].num_of_dif_pri = 1;
  937. help_data->num_of_pg++;
  938. }
  939. }
  940. DP(BNX2X_MSG_DCB,
  941. "add_traf_type %d pg_found %s num_of_pg %d\n",
  942. add_traf_type, (false == pg_found) ? "NO" : "YES",
  943. help_data->num_of_pg);
  944. }
  945. }
  946. static void bnx2x_dcbx_ets_disabled_entry_data(struct bnx2x *bp,
  947. struct cos_help_data *cos_data,
  948. u32 pri_join_mask)
  949. {
  950. /* Only one priority than only one COS */
  951. cos_data->data[0].pausable =
  952. IS_DCBX_PFC_PRI_ONLY_PAUSE(bp, pri_join_mask);
  953. cos_data->data[0].pri_join_mask = pri_join_mask;
  954. cos_data->data[0].cos_bw = 100;
  955. cos_data->num_of_cos = 1;
  956. }
  957. static inline void bnx2x_dcbx_add_to_cos_bw(struct bnx2x *bp,
  958. struct cos_entry_help_data *data,
  959. u8 pg_bw)
  960. {
  961. if (data->cos_bw == DCBX_INVALID_COS_BW)
  962. data->cos_bw = pg_bw;
  963. else
  964. data->cos_bw += pg_bw;
  965. }
  966. static void bnx2x_dcbx_separate_pauseable_from_non(struct bnx2x *bp,
  967. struct cos_help_data *cos_data,
  968. u32 *pg_pri_orginal_spread,
  969. struct dcbx_ets_feature *ets)
  970. {
  971. u32 pri_tested = 0;
  972. u8 i = 0;
  973. u8 entry = 0;
  974. u8 pg_entry = 0;
  975. u8 num_of_pri = LLFC_DRIVER_TRAFFIC_TYPE_MAX;
  976. cos_data->data[0].pausable = true;
  977. cos_data->data[1].pausable = false;
  978. cos_data->data[0].pri_join_mask = cos_data->data[1].pri_join_mask = 0;
  979. for (i = 0 ; i < num_of_pri ; i++) {
  980. pri_tested = 1 << bp->dcbx_port_params.
  981. app.traffic_type_priority[i];
  982. if (pri_tested & DCBX_PFC_PRI_NON_PAUSE_MASK(bp)) {
  983. cos_data->data[1].pri_join_mask |= pri_tested;
  984. entry = 1;
  985. } else {
  986. cos_data->data[0].pri_join_mask |= pri_tested;
  987. entry = 0;
  988. }
  989. pg_entry = (u8)pg_pri_orginal_spread[bp->dcbx_port_params.
  990. app.traffic_type_priority[i]];
  991. /* There can be only one strict pg */
  992. if (pg_entry < DCBX_MAX_NUM_PG_BW_ENTRIES)
  993. bnx2x_dcbx_add_to_cos_bw(bp, &cos_data->data[entry],
  994. DCBX_PG_BW_GET(ets->pg_bw_tbl, pg_entry));
  995. else
  996. /* If we join a group and one is strict
  997. * than the bw rulls */
  998. cos_data->data[entry].strict =
  999. BNX2X_DCBX_STRICT_COS_HIGHEST;
  1000. }
  1001. if ((0 == cos_data->data[0].pri_join_mask) &&
  1002. (0 == cos_data->data[1].pri_join_mask))
  1003. BNX2X_ERR("dcbx error: Both groups must have priorities\n");
  1004. }
  1005. #ifndef POWER_OF_2
  1006. #define POWER_OF_2(x) ((0 != x) && (0 == (x & (x-1))))
  1007. #endif
  1008. static void bnx2x_dcbx_2cos_limit_cee_single_pg_to_cos_params(struct bnx2x *bp,
  1009. struct pg_help_data *pg_help_data,
  1010. struct cos_help_data *cos_data,
  1011. u32 pri_join_mask,
  1012. u8 num_of_dif_pri)
  1013. {
  1014. u8 i = 0;
  1015. u32 pri_tested = 0;
  1016. u32 pri_mask_without_pri = 0;
  1017. u32 *ttp = bp->dcbx_port_params.app.traffic_type_priority;
  1018. /*debug*/
  1019. if (num_of_dif_pri == 1) {
  1020. bnx2x_dcbx_ets_disabled_entry_data(bp, cos_data, pri_join_mask);
  1021. return;
  1022. }
  1023. /* single priority group */
  1024. if (pg_help_data->data[0].pg < DCBX_MAX_NUM_PG_BW_ENTRIES) {
  1025. /* If there are both pauseable and non-pauseable priorities,
  1026. * the pauseable priorities go to the first queue and
  1027. * the non-pauseable priorities go to the second queue.
  1028. */
  1029. if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp, pri_join_mask)) {
  1030. /* Pauseable */
  1031. cos_data->data[0].pausable = true;
  1032. /* Non pauseable.*/
  1033. cos_data->data[1].pausable = false;
  1034. if (2 == num_of_dif_pri) {
  1035. cos_data->data[0].cos_bw = 50;
  1036. cos_data->data[1].cos_bw = 50;
  1037. }
  1038. if (3 == num_of_dif_pri) {
  1039. if (POWER_OF_2(DCBX_PFC_PRI_GET_PAUSE(bp,
  1040. pri_join_mask))) {
  1041. cos_data->data[0].cos_bw = 33;
  1042. cos_data->data[1].cos_bw = 67;
  1043. } else {
  1044. cos_data->data[0].cos_bw = 67;
  1045. cos_data->data[1].cos_bw = 33;
  1046. }
  1047. }
  1048. } else if (IS_DCBX_PFC_PRI_ONLY_PAUSE(bp, pri_join_mask)) {
  1049. /* If there are only pauseable priorities,
  1050. * then one/two priorities go to the first queue
  1051. * and one priority goes to the second queue.
  1052. */
  1053. if (2 == num_of_dif_pri) {
  1054. cos_data->data[0].cos_bw = 50;
  1055. cos_data->data[1].cos_bw = 50;
  1056. } else {
  1057. cos_data->data[0].cos_bw = 67;
  1058. cos_data->data[1].cos_bw = 33;
  1059. }
  1060. cos_data->data[1].pausable = true;
  1061. cos_data->data[0].pausable = true;
  1062. /* All priorities except FCOE */
  1063. cos_data->data[0].pri_join_mask = (pri_join_mask &
  1064. ((u8)~(1 << ttp[LLFC_TRAFFIC_TYPE_FCOE])));
  1065. /* Only FCOE priority.*/
  1066. cos_data->data[1].pri_join_mask =
  1067. (1 << ttp[LLFC_TRAFFIC_TYPE_FCOE]);
  1068. } else
  1069. /* If there are only non-pauseable priorities,
  1070. * they will all go to the same queue.
  1071. */
  1072. bnx2x_dcbx_ets_disabled_entry_data(bp,
  1073. cos_data, pri_join_mask);
  1074. } else {
  1075. /* priority group which is not BW limited (PG#15):*/
  1076. if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp, pri_join_mask)) {
  1077. /* If there are both pauseable and non-pauseable
  1078. * priorities, the pauseable priorities go to the first
  1079. * queue and the non-pauseable priorities
  1080. * go to the second queue.
  1081. */
  1082. if (DCBX_PFC_PRI_GET_PAUSE(bp, pri_join_mask) >
  1083. DCBX_PFC_PRI_GET_NON_PAUSE(bp, pri_join_mask)) {
  1084. cos_data->data[0].strict =
  1085. BNX2X_DCBX_STRICT_COS_HIGHEST;
  1086. cos_data->data[1].strict =
  1087. BNX2X_DCBX_STRICT_COS_NEXT_LOWER_PRI(
  1088. BNX2X_DCBX_STRICT_COS_HIGHEST);
  1089. } else {
  1090. cos_data->data[0].strict =
  1091. BNX2X_DCBX_STRICT_COS_NEXT_LOWER_PRI(
  1092. BNX2X_DCBX_STRICT_COS_HIGHEST);
  1093. cos_data->data[1].strict =
  1094. BNX2X_DCBX_STRICT_COS_HIGHEST;
  1095. }
  1096. /* Pauseable */
  1097. cos_data->data[0].pausable = true;
  1098. /* Non pause-able.*/
  1099. cos_data->data[1].pausable = false;
  1100. } else {
  1101. /* If there are only pauseable priorities or
  1102. * only non-pauseable,* the lower priorities go
  1103. * to the first queue and the higherpriorities go
  1104. * to the second queue.
  1105. */
  1106. cos_data->data[0].pausable =
  1107. cos_data->data[1].pausable =
  1108. IS_DCBX_PFC_PRI_ONLY_PAUSE(bp, pri_join_mask);
  1109. for (i = 0 ; i < LLFC_DRIVER_TRAFFIC_TYPE_MAX; i++) {
  1110. pri_tested = 1 << bp->dcbx_port_params.
  1111. app.traffic_type_priority[i];
  1112. /* Remove priority tested */
  1113. pri_mask_without_pri =
  1114. (pri_join_mask & ((u8)(~pri_tested)));
  1115. if (pri_mask_without_pri < pri_tested)
  1116. break;
  1117. }
  1118. if (i == LLFC_DRIVER_TRAFFIC_TYPE_MAX)
  1119. BNX2X_ERR("Invalid value for pri_join_mask - could not find a priority\n");
  1120. cos_data->data[0].pri_join_mask = pri_mask_without_pri;
  1121. cos_data->data[1].pri_join_mask = pri_tested;
  1122. /* Both queues are strict priority,
  1123. * and that with the highest priority
  1124. * gets the highest strict priority in the arbiter.
  1125. */
  1126. cos_data->data[0].strict =
  1127. BNX2X_DCBX_STRICT_COS_NEXT_LOWER_PRI(
  1128. BNX2X_DCBX_STRICT_COS_HIGHEST);
  1129. cos_data->data[1].strict =
  1130. BNX2X_DCBX_STRICT_COS_HIGHEST;
  1131. }
  1132. }
  1133. }
  1134. static void bnx2x_dcbx_2cos_limit_cee_two_pg_to_cos_params(
  1135. struct bnx2x *bp,
  1136. struct pg_help_data *pg_help_data,
  1137. struct dcbx_ets_feature *ets,
  1138. struct cos_help_data *cos_data,
  1139. u32 *pg_pri_orginal_spread,
  1140. u32 pri_join_mask,
  1141. u8 num_of_dif_pri)
  1142. {
  1143. u8 i = 0;
  1144. u8 pg[DCBX_COS_MAX_NUM_E2] = { 0 };
  1145. /* If there are both pauseable and non-pauseable priorities,
  1146. * the pauseable priorities go to the first queue and
  1147. * the non-pauseable priorities go to the second queue.
  1148. */
  1149. if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp, pri_join_mask)) {
  1150. if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp,
  1151. pg_help_data->data[0].pg_priority) ||
  1152. IS_DCBX_PFC_PRI_MIX_PAUSE(bp,
  1153. pg_help_data->data[1].pg_priority)) {
  1154. /* If one PG contains both pauseable and
  1155. * non-pauseable priorities then ETS is disabled.
  1156. */
  1157. bnx2x_dcbx_separate_pauseable_from_non(bp, cos_data,
  1158. pg_pri_orginal_spread, ets);
  1159. bp->dcbx_port_params.ets.enabled = false;
  1160. return;
  1161. }
  1162. /* Pauseable */
  1163. cos_data->data[0].pausable = true;
  1164. /* Non pauseable. */
  1165. cos_data->data[1].pausable = false;
  1166. if (IS_DCBX_PFC_PRI_ONLY_PAUSE(bp,
  1167. pg_help_data->data[0].pg_priority)) {
  1168. /* 0 is pauseable */
  1169. cos_data->data[0].pri_join_mask =
  1170. pg_help_data->data[0].pg_priority;
  1171. pg[0] = pg_help_data->data[0].pg;
  1172. cos_data->data[1].pri_join_mask =
  1173. pg_help_data->data[1].pg_priority;
  1174. pg[1] = pg_help_data->data[1].pg;
  1175. } else {/* 1 is pauseable */
  1176. cos_data->data[0].pri_join_mask =
  1177. pg_help_data->data[1].pg_priority;
  1178. pg[0] = pg_help_data->data[1].pg;
  1179. cos_data->data[1].pri_join_mask =
  1180. pg_help_data->data[0].pg_priority;
  1181. pg[1] = pg_help_data->data[0].pg;
  1182. }
  1183. } else {
  1184. /* If there are only pauseable priorities or
  1185. * only non-pauseable, each PG goes to a queue.
  1186. */
  1187. cos_data->data[0].pausable = cos_data->data[1].pausable =
  1188. IS_DCBX_PFC_PRI_ONLY_PAUSE(bp, pri_join_mask);
  1189. cos_data->data[0].pri_join_mask =
  1190. pg_help_data->data[0].pg_priority;
  1191. pg[0] = pg_help_data->data[0].pg;
  1192. cos_data->data[1].pri_join_mask =
  1193. pg_help_data->data[1].pg_priority;
  1194. pg[1] = pg_help_data->data[1].pg;
  1195. }
  1196. /* There can be only one strict pg */
  1197. for (i = 0 ; i < ARRAY_SIZE(pg); i++) {
  1198. if (pg[i] < DCBX_MAX_NUM_PG_BW_ENTRIES)
  1199. cos_data->data[i].cos_bw =
  1200. DCBX_PG_BW_GET(ets->pg_bw_tbl, pg[i]);
  1201. else
  1202. cos_data->data[i].strict =
  1203. BNX2X_DCBX_STRICT_COS_HIGHEST;
  1204. }
  1205. }
  1206. static int bnx2x_dcbx_join_pgs(
  1207. struct bnx2x *bp,
  1208. struct dcbx_ets_feature *ets,
  1209. struct pg_help_data *pg_help_data,
  1210. u8 required_num_of_pg)
  1211. {
  1212. u8 entry_joined = pg_help_data->num_of_pg - 1;
  1213. u8 entry_removed = entry_joined + 1;
  1214. u8 pg_joined = 0;
  1215. if (required_num_of_pg == 0 || ARRAY_SIZE(pg_help_data->data)
  1216. <= pg_help_data->num_of_pg) {
  1217. BNX2X_ERR("required_num_of_pg can't be zero\n");
  1218. return -EINVAL;
  1219. }
  1220. while (required_num_of_pg < pg_help_data->num_of_pg) {
  1221. entry_joined = pg_help_data->num_of_pg - 2;
  1222. entry_removed = entry_joined + 1;
  1223. /* protect index */
  1224. entry_removed %= ARRAY_SIZE(pg_help_data->data);
  1225. pg_help_data->data[entry_joined].pg_priority |=
  1226. pg_help_data->data[entry_removed].pg_priority;
  1227. pg_help_data->data[entry_joined].num_of_dif_pri +=
  1228. pg_help_data->data[entry_removed].num_of_dif_pri;
  1229. if (pg_help_data->data[entry_joined].pg == DCBX_STRICT_PRI_PG ||
  1230. pg_help_data->data[entry_removed].pg == DCBX_STRICT_PRI_PG)
  1231. /* Entries joined strict priority rules */
  1232. pg_help_data->data[entry_joined].pg =
  1233. DCBX_STRICT_PRI_PG;
  1234. else {
  1235. /* Entries can be joined join BW */
  1236. pg_joined = DCBX_PG_BW_GET(ets->pg_bw_tbl,
  1237. pg_help_data->data[entry_joined].pg) +
  1238. DCBX_PG_BW_GET(ets->pg_bw_tbl,
  1239. pg_help_data->data[entry_removed].pg);
  1240. DCBX_PG_BW_SET(ets->pg_bw_tbl,
  1241. pg_help_data->data[entry_joined].pg, pg_joined);
  1242. }
  1243. /* Joined the entries */
  1244. pg_help_data->num_of_pg--;
  1245. }
  1246. return 0;
  1247. }
  1248. static void bnx2x_dcbx_2cos_limit_cee_three_pg_to_cos_params(
  1249. struct bnx2x *bp,
  1250. struct pg_help_data *pg_help_data,
  1251. struct dcbx_ets_feature *ets,
  1252. struct cos_help_data *cos_data,
  1253. u32 *pg_pri_orginal_spread,
  1254. u32 pri_join_mask,
  1255. u8 num_of_dif_pri)
  1256. {
  1257. u8 i = 0;
  1258. u32 pri_tested = 0;
  1259. u8 entry = 0;
  1260. u8 pg_entry = 0;
  1261. bool b_found_strict = false;
  1262. u8 num_of_pri = LLFC_DRIVER_TRAFFIC_TYPE_MAX;
  1263. cos_data->data[0].pri_join_mask = cos_data->data[1].pri_join_mask = 0;
  1264. /* If there are both pauseable and non-pauseable priorities,
  1265. * the pauseable priorities go to the first queue and the
  1266. * non-pauseable priorities go to the second queue.
  1267. */
  1268. if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp, pri_join_mask))
  1269. bnx2x_dcbx_separate_pauseable_from_non(bp,
  1270. cos_data, pg_pri_orginal_spread, ets);
  1271. else {
  1272. /* If two BW-limited PG-s were combined to one queue,
  1273. * the BW is their sum.
  1274. *
  1275. * If there are only pauseable priorities or only non-pauseable,
  1276. * and there are both BW-limited and non-BW-limited PG-s,
  1277. * the BW-limited PG/s go to one queue and the non-BW-limited
  1278. * PG/s go to the second queue.
  1279. *
  1280. * If there are only pauseable priorities or only non-pauseable
  1281. * and all are BW limited, then two priorities go to the first
  1282. * queue and one priority goes to the second queue.
  1283. *
  1284. * We will join this two cases:
  1285. * if one is BW limited it will go to the secoend queue
  1286. * otherwise the last priority will get it
  1287. */
  1288. cos_data->data[0].pausable = cos_data->data[1].pausable =
  1289. IS_DCBX_PFC_PRI_ONLY_PAUSE(bp, pri_join_mask);
  1290. for (i = 0 ; i < num_of_pri; i++) {
  1291. pri_tested = 1 << bp->dcbx_port_params.
  1292. app.traffic_type_priority[i];
  1293. pg_entry = (u8)pg_pri_orginal_spread[bp->
  1294. dcbx_port_params.app.traffic_type_priority[i]];
  1295. if (pg_entry < DCBX_MAX_NUM_PG_BW_ENTRIES) {
  1296. entry = 0;
  1297. if (i == (num_of_pri-1) &&
  1298. false == b_found_strict)
  1299. /* last entry will be handled separately
  1300. * If no priority is strict than last
  1301. * enty goes to last queue.*/
  1302. entry = 1;
  1303. cos_data->data[entry].pri_join_mask |=
  1304. pri_tested;
  1305. bnx2x_dcbx_add_to_cos_bw(bp,
  1306. &cos_data->data[entry],
  1307. DCBX_PG_BW_GET(ets->pg_bw_tbl,
  1308. pg_entry));
  1309. } else {
  1310. b_found_strict = true;
  1311. cos_data->data[1].pri_join_mask |= pri_tested;
  1312. /* If we join a group and one is strict
  1313. * than the bw rulls */
  1314. cos_data->data[1].strict =
  1315. BNX2X_DCBX_STRICT_COS_HIGHEST;
  1316. }
  1317. }
  1318. }
  1319. }
  1320. static void bnx2x_dcbx_2cos_limit_cee_fill_cos_params(struct bnx2x *bp,
  1321. struct pg_help_data *help_data,
  1322. struct dcbx_ets_feature *ets,
  1323. struct cos_help_data *cos_data,
  1324. u32 *pg_pri_orginal_spread,
  1325. u32 pri_join_mask,
  1326. u8 num_of_dif_pri)
  1327. {
  1328. /* default E2 settings */
  1329. cos_data->num_of_cos = DCBX_COS_MAX_NUM_E2;
  1330. switch (help_data->num_of_pg) {
  1331. case 1:
  1332. bnx2x_dcbx_2cos_limit_cee_single_pg_to_cos_params(
  1333. bp,
  1334. help_data,
  1335. cos_data,
  1336. pri_join_mask,
  1337. num_of_dif_pri);
  1338. break;
  1339. case 2:
  1340. bnx2x_dcbx_2cos_limit_cee_two_pg_to_cos_params(
  1341. bp,
  1342. help_data,
  1343. ets,
  1344. cos_data,
  1345. pg_pri_orginal_spread,
  1346. pri_join_mask,
  1347. num_of_dif_pri);
  1348. break;
  1349. case 3:
  1350. bnx2x_dcbx_2cos_limit_cee_three_pg_to_cos_params(
  1351. bp,
  1352. help_data,
  1353. ets,
  1354. cos_data,
  1355. pg_pri_orginal_spread,
  1356. pri_join_mask,
  1357. num_of_dif_pri);
  1358. break;
  1359. default:
  1360. BNX2X_ERR("Wrong pg_help_data.num_of_pg\n");
  1361. bnx2x_dcbx_ets_disabled_entry_data(bp,
  1362. cos_data, pri_join_mask);
  1363. }
  1364. }
  1365. static int bnx2x_dcbx_spread_strict_pri(struct bnx2x *bp,
  1366. struct cos_help_data *cos_data,
  1367. u8 entry,
  1368. u8 num_spread_of_entries,
  1369. u8 strict_app_pris)
  1370. {
  1371. u8 strict_pri = BNX2X_DCBX_STRICT_COS_HIGHEST;
  1372. u8 num_of_app_pri = MAX_PFC_PRIORITIES;
  1373. u8 app_pri_bit = 0;
  1374. while (num_spread_of_entries && num_of_app_pri > 0) {
  1375. app_pri_bit = 1 << (num_of_app_pri - 1);
  1376. if (app_pri_bit & strict_app_pris) {
  1377. struct cos_entry_help_data *data = &cos_data->
  1378. data[entry];
  1379. num_spread_of_entries--;
  1380. if (num_spread_of_entries == 0) {
  1381. /* last entry needed put all the entries left */
  1382. data->cos_bw = DCBX_INVALID_COS_BW;
  1383. data->strict = strict_pri;
  1384. data->pri_join_mask = strict_app_pris;
  1385. data->pausable = DCBX_IS_PFC_PRI_SOME_PAUSE(bp,
  1386. data->pri_join_mask);
  1387. } else {
  1388. strict_app_pris &= ~app_pri_bit;
  1389. data->cos_bw = DCBX_INVALID_COS_BW;
  1390. data->strict = strict_pri;
  1391. data->pri_join_mask = app_pri_bit;
  1392. data->pausable = DCBX_IS_PFC_PRI_SOME_PAUSE(bp,
  1393. data->pri_join_mask);
  1394. }
  1395. strict_pri =
  1396. BNX2X_DCBX_STRICT_COS_NEXT_LOWER_PRI(strict_pri);
  1397. entry++;
  1398. }
  1399. num_of_app_pri--;
  1400. }
  1401. if (num_spread_of_entries) {
  1402. BNX2X_ERR("Didn't succeed to spread strict priorities\n");
  1403. return -EINVAL;
  1404. }
  1405. return 0;
  1406. }
  1407. static u8 bnx2x_dcbx_cee_fill_strict_pri(struct bnx2x *bp,
  1408. struct cos_help_data *cos_data,
  1409. u8 entry,
  1410. u8 num_spread_of_entries,
  1411. u8 strict_app_pris)
  1412. {
  1413. if (bnx2x_dcbx_spread_strict_pri(bp, cos_data, entry,
  1414. num_spread_of_entries,
  1415. strict_app_pris)) {
  1416. struct cos_entry_help_data *data = &cos_data->
  1417. data[entry];
  1418. /* Fill BW entry */
  1419. data->cos_bw = DCBX_INVALID_COS_BW;
  1420. data->strict = BNX2X_DCBX_STRICT_COS_HIGHEST;
  1421. data->pri_join_mask = strict_app_pris;
  1422. data->pausable = DCBX_IS_PFC_PRI_SOME_PAUSE(bp,
  1423. data->pri_join_mask);
  1424. return 1;
  1425. }
  1426. return num_spread_of_entries;
  1427. }
  1428. static void bnx2x_dcbx_cee_fill_cos_params(struct bnx2x *bp,
  1429. struct pg_help_data *help_data,
  1430. struct dcbx_ets_feature *ets,
  1431. struct cos_help_data *cos_data,
  1432. u32 pri_join_mask)
  1433. {
  1434. u8 need_num_of_entries = 0;
  1435. u8 i = 0;
  1436. u8 entry = 0;
  1437. /*
  1438. * if the number of requested PG-s in CEE is greater than 3
  1439. * then the results are not determined since this is a violation
  1440. * of the standard.
  1441. */
  1442. if (help_data->num_of_pg > DCBX_COS_MAX_NUM_E3B0) {
  1443. if (bnx2x_dcbx_join_pgs(bp, ets, help_data,
  1444. DCBX_COS_MAX_NUM_E3B0)) {
  1445. BNX2X_ERR("Unable to reduce the number of PGs - we will disables ETS\n");
  1446. bnx2x_dcbx_ets_disabled_entry_data(bp, cos_data,
  1447. pri_join_mask);
  1448. return;
  1449. }
  1450. }
  1451. for (i = 0 ; i < help_data->num_of_pg; i++) {
  1452. struct pg_entry_help_data *pg = &help_data->data[i];
  1453. if (pg->pg < DCBX_MAX_NUM_PG_BW_ENTRIES) {
  1454. struct cos_entry_help_data *data = &cos_data->
  1455. data[entry];
  1456. /* Fill BW entry */
  1457. data->cos_bw = DCBX_PG_BW_GET(ets->pg_bw_tbl, pg->pg);
  1458. data->strict = BNX2X_DCBX_STRICT_INVALID;
  1459. data->pri_join_mask = pg->pg_priority;
  1460. data->pausable = DCBX_IS_PFC_PRI_SOME_PAUSE(bp,
  1461. data->pri_join_mask);
  1462. entry++;
  1463. } else {
  1464. need_num_of_entries = min_t(u8,
  1465. (u8)pg->num_of_dif_pri,
  1466. (u8)DCBX_COS_MAX_NUM_E3B0 -
  1467. help_data->num_of_pg + 1);
  1468. /*
  1469. * If there are still VOQ-s which have no associated PG,
  1470. * then associate these VOQ-s to PG15. These PG-s will
  1471. * be used for SP between priorities on PG15.
  1472. */
  1473. entry += bnx2x_dcbx_cee_fill_strict_pri(bp, cos_data,
  1474. entry, need_num_of_entries, pg->pg_priority);
  1475. }
  1476. }
  1477. /* the entry will represent the number of COSes used */
  1478. cos_data->num_of_cos = entry;
  1479. }
  1480. static void bnx2x_dcbx_fill_cos_params(struct bnx2x *bp,
  1481. struct pg_help_data *help_data,
  1482. struct dcbx_ets_feature *ets,
  1483. u32 *pg_pri_orginal_spread)
  1484. {
  1485. struct cos_help_data cos_data;
  1486. u8 i = 0;
  1487. u32 pri_join_mask = 0;
  1488. u8 num_of_dif_pri = 0;
  1489. memset(&cos_data, 0, sizeof(cos_data));
  1490. /* Validate the pg value */
  1491. for (i = 0; i < help_data->num_of_pg ; i++) {
  1492. if (DCBX_STRICT_PRIORITY != help_data->data[i].pg &&
  1493. DCBX_MAX_NUM_PG_BW_ENTRIES <= help_data->data[i].pg)
  1494. BNX2X_ERR("Invalid pg[%d] data %x\n", i,
  1495. help_data->data[i].pg);
  1496. pri_join_mask |= help_data->data[i].pg_priority;
  1497. num_of_dif_pri += help_data->data[i].num_of_dif_pri;
  1498. }
  1499. /* defaults */
  1500. cos_data.num_of_cos = 1;
  1501. for (i = 0; i < ARRAY_SIZE(cos_data.data); i++) {
  1502. cos_data.data[i].pri_join_mask = 0;
  1503. cos_data.data[i].pausable = false;
  1504. cos_data.data[i].strict = BNX2X_DCBX_STRICT_INVALID;
  1505. cos_data.data[i].cos_bw = DCBX_INVALID_COS_BW;
  1506. }
  1507. if (CHIP_IS_E3B0(bp))
  1508. bnx2x_dcbx_cee_fill_cos_params(bp, help_data, ets,
  1509. &cos_data, pri_join_mask);
  1510. else /* E2 + E3A0 */
  1511. bnx2x_dcbx_2cos_limit_cee_fill_cos_params(bp,
  1512. help_data, ets,
  1513. &cos_data,
  1514. pg_pri_orginal_spread,
  1515. pri_join_mask,
  1516. num_of_dif_pri);
  1517. for (i = 0; i < cos_data.num_of_cos ; i++) {
  1518. struct bnx2x_dcbx_cos_params *p =
  1519. &bp->dcbx_port_params.ets.cos_params[i];
  1520. p->strict = cos_data.data[i].strict;
  1521. p->bw_tbl = cos_data.data[i].cos_bw;
  1522. p->pri_bitmask = cos_data.data[i].pri_join_mask;
  1523. p->pauseable = cos_data.data[i].pausable;
  1524. /* sanity */
  1525. if (p->bw_tbl != DCBX_INVALID_COS_BW ||
  1526. p->strict != BNX2X_DCBX_STRICT_INVALID) {
  1527. if (p->pri_bitmask == 0)
  1528. BNX2X_ERR("Invalid pri_bitmask for %d\n", i);
  1529. if (CHIP_IS_E2(bp) || CHIP_IS_E3A0(bp)) {
  1530. if (p->pauseable &&
  1531. DCBX_PFC_PRI_GET_NON_PAUSE(bp,
  1532. p->pri_bitmask) != 0)
  1533. BNX2X_ERR("Inconsistent config for pausable COS %d\n",
  1534. i);
  1535. if (!p->pauseable &&
  1536. DCBX_PFC_PRI_GET_PAUSE(bp,
  1537. p->pri_bitmask) != 0)
  1538. BNX2X_ERR("Inconsistent config for nonpausable COS %d\n",
  1539. i);
  1540. }
  1541. }
  1542. if (p->pauseable)
  1543. DP(BNX2X_MSG_DCB, "COS %d PAUSABLE prijoinmask 0x%x\n",
  1544. i, cos_data.data[i].pri_join_mask);
  1545. else
  1546. DP(BNX2X_MSG_DCB,
  1547. "COS %d NONPAUSABLE prijoinmask 0x%x\n",
  1548. i, cos_data.data[i].pri_join_mask);
  1549. }
  1550. bp->dcbx_port_params.ets.num_of_cos = cos_data.num_of_cos ;
  1551. }
  1552. static void bnx2x_dcbx_get_ets_pri_pg_tbl(struct bnx2x *bp,
  1553. u32 *set_configuration_ets_pg,
  1554. u32 *pri_pg_tbl)
  1555. {
  1556. int i;
  1557. for (i = 0; i < DCBX_MAX_NUM_PRI_PG_ENTRIES; i++) {
  1558. set_configuration_ets_pg[i] = DCBX_PRI_PG_GET(pri_pg_tbl, i);
  1559. DP(BNX2X_MSG_DCB, "set_configuration_ets_pg[%d] = 0x%x\n",
  1560. i, set_configuration_ets_pg[i]);
  1561. }
  1562. }
  1563. static void bnx2x_dcbx_fw_struct(struct bnx2x *bp,
  1564. struct bnx2x_func_tx_start_params *pfc_fw_cfg)
  1565. {
  1566. u16 pri_bit = 0;
  1567. u8 cos = 0, pri = 0;
  1568. struct priority_cos *tt2cos;
  1569. u32 *ttp = bp->dcbx_port_params.app.traffic_type_priority;
  1570. memset(pfc_fw_cfg, 0, sizeof(*pfc_fw_cfg));
  1571. /* to disable DCB - the structure must be zeroed */
  1572. if (bp->dcbx_error & DCBX_REMOTE_MIB_ERROR)
  1573. return;
  1574. /*shortcut*/
  1575. tt2cos = pfc_fw_cfg->traffic_type_to_priority_cos;
  1576. /* Fw version should be incremented each update */
  1577. pfc_fw_cfg->dcb_version = ++bp->dcb_version;
  1578. pfc_fw_cfg->dcb_enabled = 1;
  1579. /* Fill priority parameters */
  1580. for (pri = 0; pri < LLFC_DRIVER_TRAFFIC_TYPE_MAX; pri++) {
  1581. tt2cos[pri].priority = ttp[pri];
  1582. pri_bit = 1 << tt2cos[pri].priority;
  1583. /* Fill COS parameters based on COS calculated to
  1584. * make it more general for future use */
  1585. for (cos = 0; cos < bp->dcbx_port_params.ets.num_of_cos; cos++)
  1586. if (bp->dcbx_port_params.ets.cos_params[cos].
  1587. pri_bitmask & pri_bit)
  1588. tt2cos[pri].cos = cos;
  1589. }
  1590. /* we never want the FW to add a 0 vlan tag */
  1591. pfc_fw_cfg->dont_add_pri_0_en = 1;
  1592. bnx2x_dcbx_print_cos_params(bp, pfc_fw_cfg);
  1593. }
  1594. void bnx2x_dcbx_pmf_update(struct bnx2x *bp)
  1595. {
  1596. /* if we need to syncronize DCBX result from prev PMF
  1597. * read it from shmem and update bp and netdev accordingly
  1598. */
  1599. if (SHMEM2_HAS(bp, drv_flags) &&
  1600. GET_FLAGS(SHMEM2_RD(bp, drv_flags), 1 << DRV_FLAGS_DCB_CONFIGURED)) {
  1601. /* Read neg results if dcbx is in the FW */
  1602. if (bnx2x_dcbx_read_shmem_neg_results(bp))
  1603. return;
  1604. bnx2x_dump_dcbx_drv_param(bp, &bp->dcbx_local_feat,
  1605. bp->dcbx_error);
  1606. bnx2x_get_dcbx_drv_param(bp, &bp->dcbx_local_feat,
  1607. bp->dcbx_error);
  1608. #ifdef BCM_DCBNL
  1609. /*
  1610. * Add new app tlvs to dcbnl
  1611. */
  1612. bnx2x_dcbnl_update_applist(bp, false);
  1613. /*
  1614. * Send a notification for the new negotiated parameters
  1615. */
  1616. dcbnl_cee_notify(bp->dev, RTM_GETDCB, DCB_CMD_CEE_GET, 0, 0);
  1617. #endif
  1618. /*
  1619. * reconfigure the netdevice with the results of the new
  1620. * dcbx negotiation.
  1621. */
  1622. bnx2x_dcbx_update_tc_mapping(bp);
  1623. }
  1624. }
  1625. /* DCB netlink */
  1626. #ifdef BCM_DCBNL
  1627. #define BNX2X_DCBX_CAPS (DCB_CAP_DCBX_LLD_MANAGED | \
  1628. DCB_CAP_DCBX_VER_CEE | DCB_CAP_DCBX_STATIC)
  1629. static inline bool bnx2x_dcbnl_set_valid(struct bnx2x *bp)
  1630. {
  1631. /* validate dcbnl call that may change HW state:
  1632. * DCB is on and DCBX mode was SUCCESSFULLY set by the user.
  1633. */
  1634. return bp->dcb_state && bp->dcbx_mode_uset;
  1635. }
  1636. static u8 bnx2x_dcbnl_get_state(struct net_device *netdev)
  1637. {
  1638. struct bnx2x *bp = netdev_priv(netdev);
  1639. DP(BNX2X_MSG_DCB, "state = %d\n", bp->dcb_state);
  1640. return bp->dcb_state;
  1641. }
  1642. static u8 bnx2x_dcbnl_set_state(struct net_device *netdev, u8 state)
  1643. {
  1644. struct bnx2x *bp = netdev_priv(netdev);
  1645. DP(BNX2X_MSG_DCB, "state = %s\n", state ? "on" : "off");
  1646. bnx2x_dcbx_set_state(bp, (state ? true : false), bp->dcbx_enabled);
  1647. return 0;
  1648. }
  1649. static void bnx2x_dcbnl_get_perm_hw_addr(struct net_device *netdev,
  1650. u8 *perm_addr)
  1651. {
  1652. struct bnx2x *bp = netdev_priv(netdev);
  1653. DP(BNX2X_MSG_DCB, "GET-PERM-ADDR\n");
  1654. /* first the HW mac address */
  1655. memcpy(perm_addr, netdev->dev_addr, netdev->addr_len);
  1656. #ifdef BCM_CNIC
  1657. /* second SAN address */
  1658. memcpy(perm_addr+netdev->addr_len, bp->fip_mac, netdev->addr_len);
  1659. #endif
  1660. }
  1661. static void bnx2x_dcbnl_set_pg_tccfg_tx(struct net_device *netdev, int prio,
  1662. u8 prio_type, u8 pgid, u8 bw_pct,
  1663. u8 up_map)
  1664. {
  1665. struct bnx2x *bp = netdev_priv(netdev);
  1666. DP(BNX2X_MSG_DCB, "prio[%d] = %d\n", prio, pgid);
  1667. if (!bnx2x_dcbnl_set_valid(bp) || prio >= DCBX_MAX_NUM_PRI_PG_ENTRIES)
  1668. return;
  1669. /**
  1670. * bw_pct ingnored - band-width percentage devision between user
  1671. * priorities within the same group is not
  1672. * standard and hence not supported
  1673. *
  1674. * prio_type igonred - priority levels within the same group are not
  1675. * standard and hence are not supported. According
  1676. * to the standard pgid 15 is dedicated to strict
  1677. * prioirty traffic (on the port level).
  1678. *
  1679. * up_map ignored
  1680. */
  1681. bp->dcbx_config_params.admin_configuration_ets_pg[prio] = pgid;
  1682. bp->dcbx_config_params.admin_ets_configuration_tx_enable = 1;
  1683. }
  1684. static void bnx2x_dcbnl_set_pg_bwgcfg_tx(struct net_device *netdev,
  1685. int pgid, u8 bw_pct)
  1686. {
  1687. struct bnx2x *bp = netdev_priv(netdev);
  1688. DP(BNX2X_MSG_DCB, "pgid[%d] = %d\n", pgid, bw_pct);
  1689. if (!bnx2x_dcbnl_set_valid(bp) || pgid >= DCBX_MAX_NUM_PG_BW_ENTRIES)
  1690. return;
  1691. bp->dcbx_config_params.admin_configuration_bw_precentage[pgid] = bw_pct;
  1692. bp->dcbx_config_params.admin_ets_configuration_tx_enable = 1;
  1693. }
  1694. static void bnx2x_dcbnl_set_pg_tccfg_rx(struct net_device *netdev, int prio,
  1695. u8 prio_type, u8 pgid, u8 bw_pct,
  1696. u8 up_map)
  1697. {
  1698. struct bnx2x *bp = netdev_priv(netdev);
  1699. DP(BNX2X_MSG_DCB, "Nothing to set; No RX support\n");
  1700. }
  1701. static void bnx2x_dcbnl_set_pg_bwgcfg_rx(struct net_device *netdev,
  1702. int pgid, u8 bw_pct)
  1703. {
  1704. struct bnx2x *bp = netdev_priv(netdev);
  1705. DP(BNX2X_MSG_DCB, "Nothing to set; No RX support\n");
  1706. }
  1707. static void bnx2x_dcbnl_get_pg_tccfg_tx(struct net_device *netdev, int prio,
  1708. u8 *prio_type, u8 *pgid, u8 *bw_pct,
  1709. u8 *up_map)
  1710. {
  1711. struct bnx2x *bp = netdev_priv(netdev);
  1712. DP(BNX2X_MSG_DCB, "prio = %d\n", prio);
  1713. /**
  1714. * bw_pct ingnored - band-width percentage devision between user
  1715. * priorities within the same group is not
  1716. * standard and hence not supported
  1717. *
  1718. * prio_type igonred - priority levels within the same group are not
  1719. * standard and hence are not supported. According
  1720. * to the standard pgid 15 is dedicated to strict
  1721. * prioirty traffic (on the port level).
  1722. *
  1723. * up_map ignored
  1724. */
  1725. *up_map = *bw_pct = *prio_type = *pgid = 0;
  1726. if (!bp->dcb_state || prio >= DCBX_MAX_NUM_PRI_PG_ENTRIES)
  1727. return;
  1728. *pgid = DCBX_PRI_PG_GET(bp->dcbx_local_feat.ets.pri_pg_tbl, prio);
  1729. }
  1730. static void bnx2x_dcbnl_get_pg_bwgcfg_tx(struct net_device *netdev,
  1731. int pgid, u8 *bw_pct)
  1732. {
  1733. struct bnx2x *bp = netdev_priv(netdev);
  1734. DP(BNX2X_MSG_DCB, "pgid = %d\n", pgid);
  1735. *bw_pct = 0;
  1736. if (!bp->dcb_state || pgid >= DCBX_MAX_NUM_PG_BW_ENTRIES)
  1737. return;
  1738. *bw_pct = DCBX_PG_BW_GET(bp->dcbx_local_feat.ets.pg_bw_tbl, pgid);
  1739. }
  1740. static void bnx2x_dcbnl_get_pg_tccfg_rx(struct net_device *netdev, int prio,
  1741. u8 *prio_type, u8 *pgid, u8 *bw_pct,
  1742. u8 *up_map)
  1743. {
  1744. struct bnx2x *bp = netdev_priv(netdev);
  1745. DP(BNX2X_MSG_DCB, "Nothing to get; No RX support\n");
  1746. *prio_type = *pgid = *bw_pct = *up_map = 0;
  1747. }
  1748. static void bnx2x_dcbnl_get_pg_bwgcfg_rx(struct net_device *netdev,
  1749. int pgid, u8 *bw_pct)
  1750. {
  1751. struct bnx2x *bp = netdev_priv(netdev);
  1752. DP(BNX2X_MSG_DCB, "Nothing to get; No RX support\n");
  1753. *bw_pct = 0;
  1754. }
  1755. static void bnx2x_dcbnl_set_pfc_cfg(struct net_device *netdev, int prio,
  1756. u8 setting)
  1757. {
  1758. struct bnx2x *bp = netdev_priv(netdev);
  1759. DP(BNX2X_MSG_DCB, "prio[%d] = %d\n", prio, setting);
  1760. if (!bnx2x_dcbnl_set_valid(bp) || prio >= MAX_PFC_PRIORITIES)
  1761. return;
  1762. bp->dcbx_config_params.admin_pfc_bitmap |= ((setting ? 1 : 0) << prio);
  1763. if (setting)
  1764. bp->dcbx_config_params.admin_pfc_tx_enable = 1;
  1765. }
  1766. static void bnx2x_dcbnl_get_pfc_cfg(struct net_device *netdev, int prio,
  1767. u8 *setting)
  1768. {
  1769. struct bnx2x *bp = netdev_priv(netdev);
  1770. DP(BNX2X_MSG_DCB, "prio = %d\n", prio);
  1771. *setting = 0;
  1772. if (!bp->dcb_state || prio >= MAX_PFC_PRIORITIES)
  1773. return;
  1774. *setting = (bp->dcbx_local_feat.pfc.pri_en_bitmap >> prio) & 0x1;
  1775. }
  1776. static u8 bnx2x_dcbnl_set_all(struct net_device *netdev)
  1777. {
  1778. struct bnx2x *bp = netdev_priv(netdev);
  1779. int rc = 0;
  1780. DP(BNX2X_MSG_DCB, "SET-ALL\n");
  1781. if (!bnx2x_dcbnl_set_valid(bp))
  1782. return 1;
  1783. if (bp->recovery_state != BNX2X_RECOVERY_DONE) {
  1784. netdev_err(bp->dev,
  1785. "Handling parity error recovery. Try again later\n");
  1786. return 1;
  1787. }
  1788. if (netif_running(bp->dev))
  1789. bnx2x_dcbx_init(bp, true);
  1790. DP(BNX2X_MSG_DCB, "set_dcbx_params done (%d)\n", rc);
  1791. if (rc)
  1792. return 1;
  1793. return 0;
  1794. }
  1795. static u8 bnx2x_dcbnl_get_cap(struct net_device *netdev, int capid, u8 *cap)
  1796. {
  1797. struct bnx2x *bp = netdev_priv(netdev);
  1798. u8 rval = 0;
  1799. if (bp->dcb_state) {
  1800. switch (capid) {
  1801. case DCB_CAP_ATTR_PG:
  1802. *cap = true;
  1803. break;
  1804. case DCB_CAP_ATTR_PFC:
  1805. *cap = true;
  1806. break;
  1807. case DCB_CAP_ATTR_UP2TC:
  1808. *cap = false;
  1809. break;
  1810. case DCB_CAP_ATTR_PG_TCS:
  1811. *cap = 0x80; /* 8 priorities for PGs */
  1812. break;
  1813. case DCB_CAP_ATTR_PFC_TCS:
  1814. *cap = 0x80; /* 8 priorities for PFC */
  1815. break;
  1816. case DCB_CAP_ATTR_GSP:
  1817. *cap = true;
  1818. break;
  1819. case DCB_CAP_ATTR_BCN:
  1820. *cap = false;
  1821. break;
  1822. case DCB_CAP_ATTR_DCBX:
  1823. *cap = BNX2X_DCBX_CAPS;
  1824. break;
  1825. default:
  1826. BNX2X_ERR("Non valid capability ID\n");
  1827. rval = -EINVAL;
  1828. break;
  1829. }
  1830. } else {
  1831. DP(BNX2X_MSG_DCB, "DCB disabled\n");
  1832. rval = -EINVAL;
  1833. }
  1834. DP(BNX2X_MSG_DCB, "capid %d:%x\n", capid, *cap);
  1835. return rval;
  1836. }
  1837. static int bnx2x_dcbnl_get_numtcs(struct net_device *netdev, int tcid, u8 *num)
  1838. {
  1839. struct bnx2x *bp = netdev_priv(netdev);
  1840. u8 rval = 0;
  1841. DP(BNX2X_MSG_DCB, "tcid %d\n", tcid);
  1842. if (bp->dcb_state) {
  1843. switch (tcid) {
  1844. case DCB_NUMTCS_ATTR_PG:
  1845. *num = CHIP_IS_E3B0(bp) ? DCBX_COS_MAX_NUM_E3B0 :
  1846. DCBX_COS_MAX_NUM_E2;
  1847. break;
  1848. case DCB_NUMTCS_ATTR_PFC:
  1849. *num = CHIP_IS_E3B0(bp) ? DCBX_COS_MAX_NUM_E3B0 :
  1850. DCBX_COS_MAX_NUM_E2;
  1851. break;
  1852. default:
  1853. BNX2X_ERR("Non valid TC-ID\n");
  1854. rval = -EINVAL;
  1855. break;
  1856. }
  1857. } else {
  1858. DP(BNX2X_MSG_DCB, "DCB disabled\n");
  1859. rval = -EINVAL;
  1860. }
  1861. return rval;
  1862. }
  1863. static int bnx2x_dcbnl_set_numtcs(struct net_device *netdev, int tcid, u8 num)
  1864. {
  1865. struct bnx2x *bp = netdev_priv(netdev);
  1866. DP(BNX2X_MSG_DCB, "num tcs = %d; Not supported\n", num);
  1867. return -EINVAL;
  1868. }
  1869. static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev)
  1870. {
  1871. struct bnx2x *bp = netdev_priv(netdev);
  1872. DP(BNX2X_MSG_DCB, "state = %d\n", bp->dcbx_local_feat.pfc.enabled);
  1873. if (!bp->dcb_state)
  1874. return 0;
  1875. return bp->dcbx_local_feat.pfc.enabled;
  1876. }
  1877. static void bnx2x_dcbnl_set_pfc_state(struct net_device *netdev, u8 state)
  1878. {
  1879. struct bnx2x *bp = netdev_priv(netdev);
  1880. DP(BNX2X_MSG_DCB, "state = %s\n", state ? "on" : "off");
  1881. if (!bnx2x_dcbnl_set_valid(bp))
  1882. return;
  1883. bp->dcbx_config_params.admin_pfc_tx_enable =
  1884. bp->dcbx_config_params.admin_pfc_enable = (state ? 1 : 0);
  1885. }
  1886. static void bnx2x_admin_app_set_ent(
  1887. struct bnx2x_admin_priority_app_table *app_ent,
  1888. u8 idtype, u16 idval, u8 up)
  1889. {
  1890. app_ent->valid = 1;
  1891. switch (idtype) {
  1892. case DCB_APP_IDTYPE_ETHTYPE:
  1893. app_ent->traffic_type = TRAFFIC_TYPE_ETH;
  1894. break;
  1895. case DCB_APP_IDTYPE_PORTNUM:
  1896. app_ent->traffic_type = TRAFFIC_TYPE_PORT;
  1897. break;
  1898. default:
  1899. break; /* never gets here */
  1900. }
  1901. app_ent->app_id = idval;
  1902. app_ent->priority = up;
  1903. }
  1904. static bool bnx2x_admin_app_is_equal(
  1905. struct bnx2x_admin_priority_app_table *app_ent,
  1906. u8 idtype, u16 idval)
  1907. {
  1908. if (!app_ent->valid)
  1909. return false;
  1910. switch (idtype) {
  1911. case DCB_APP_IDTYPE_ETHTYPE:
  1912. if (app_ent->traffic_type != TRAFFIC_TYPE_ETH)
  1913. return false;
  1914. break;
  1915. case DCB_APP_IDTYPE_PORTNUM:
  1916. if (app_ent->traffic_type != TRAFFIC_TYPE_PORT)
  1917. return false;
  1918. break;
  1919. default:
  1920. return false;
  1921. }
  1922. if (app_ent->app_id != idval)
  1923. return false;
  1924. return true;
  1925. }
  1926. static int bnx2x_set_admin_app_up(struct bnx2x *bp, u8 idtype, u16 idval, u8 up)
  1927. {
  1928. int i, ff;
  1929. /* iterate over the app entries looking for idtype and idval */
  1930. for (i = 0, ff = -1; i < DCBX_CONFIG_MAX_APP_PROTOCOL; i++) {
  1931. struct bnx2x_admin_priority_app_table *app_ent =
  1932. &bp->dcbx_config_params.admin_priority_app_table[i];
  1933. if (bnx2x_admin_app_is_equal(app_ent, idtype, idval))
  1934. break;
  1935. if (ff < 0 && !app_ent->valid)
  1936. ff = i;
  1937. }
  1938. if (i < DCBX_CONFIG_MAX_APP_PROTOCOL)
  1939. /* if found overwrite up */
  1940. bp->dcbx_config_params.
  1941. admin_priority_app_table[i].priority = up;
  1942. else if (ff >= 0)
  1943. /* not found use first-free */
  1944. bnx2x_admin_app_set_ent(
  1945. &bp->dcbx_config_params.admin_priority_app_table[ff],
  1946. idtype, idval, up);
  1947. else {
  1948. /* app table is full */
  1949. BNX2X_ERR("Application table is too large\n");
  1950. return -EBUSY;
  1951. }
  1952. /* up configured, if not 0 make sure feature is enabled */
  1953. if (up)
  1954. bp->dcbx_config_params.admin_application_priority_tx_enable = 1;
  1955. return 0;
  1956. }
  1957. static u8 bnx2x_dcbnl_set_app_up(struct net_device *netdev, u8 idtype,
  1958. u16 idval, u8 up)
  1959. {
  1960. struct bnx2x *bp = netdev_priv(netdev);
  1961. DP(BNX2X_MSG_DCB, "app_type %d, app_id %x, prio bitmap %d\n",
  1962. idtype, idval, up);
  1963. if (!bnx2x_dcbnl_set_valid(bp)) {
  1964. DP(BNX2X_MSG_DCB, "dcbnl call not valid\n");
  1965. return -EINVAL;
  1966. }
  1967. /* verify idtype */
  1968. switch (idtype) {
  1969. case DCB_APP_IDTYPE_ETHTYPE:
  1970. case DCB_APP_IDTYPE_PORTNUM:
  1971. break;
  1972. default:
  1973. DP(BNX2X_MSG_DCB, "Wrong ID type\n");
  1974. return -EINVAL;
  1975. }
  1976. return bnx2x_set_admin_app_up(bp, idtype, idval, up);
  1977. }
  1978. static u8 bnx2x_dcbnl_get_dcbx(struct net_device *netdev)
  1979. {
  1980. struct bnx2x *bp = netdev_priv(netdev);
  1981. u8 state;
  1982. state = DCB_CAP_DCBX_LLD_MANAGED | DCB_CAP_DCBX_VER_CEE;
  1983. if (bp->dcbx_enabled == BNX2X_DCBX_ENABLED_ON_NEG_OFF)
  1984. state |= DCB_CAP_DCBX_STATIC;
  1985. return state;
  1986. }
  1987. static u8 bnx2x_dcbnl_set_dcbx(struct net_device *netdev, u8 state)
  1988. {
  1989. struct bnx2x *bp = netdev_priv(netdev);
  1990. DP(BNX2X_MSG_DCB, "state = %02x\n", state);
  1991. /* set dcbx mode */
  1992. if ((state & BNX2X_DCBX_CAPS) != state) {
  1993. BNX2X_ERR("Requested DCBX mode %x is beyond advertised capabilities\n",
  1994. state);
  1995. return 1;
  1996. }
  1997. if (bp->dcb_state != BNX2X_DCB_STATE_ON) {
  1998. BNX2X_ERR("DCB turned off, DCBX configuration is invalid\n");
  1999. return 1;
  2000. }
  2001. if (state & DCB_CAP_DCBX_STATIC)
  2002. bp->dcbx_enabled = BNX2X_DCBX_ENABLED_ON_NEG_OFF;
  2003. else
  2004. bp->dcbx_enabled = BNX2X_DCBX_ENABLED_ON_NEG_ON;
  2005. bp->dcbx_mode_uset = true;
  2006. return 0;
  2007. }
  2008. static u8 bnx2x_dcbnl_get_featcfg(struct net_device *netdev, int featid,
  2009. u8 *flags)
  2010. {
  2011. struct bnx2x *bp = netdev_priv(netdev);
  2012. u8 rval = 0;
  2013. DP(BNX2X_MSG_DCB, "featid %d\n", featid);
  2014. if (bp->dcb_state) {
  2015. *flags = 0;
  2016. switch (featid) {
  2017. case DCB_FEATCFG_ATTR_PG:
  2018. if (bp->dcbx_local_feat.ets.enabled)
  2019. *flags |= DCB_FEATCFG_ENABLE;
  2020. if (bp->dcbx_error & DCBX_LOCAL_ETS_ERROR)
  2021. *flags |= DCB_FEATCFG_ERROR;
  2022. break;
  2023. case DCB_FEATCFG_ATTR_PFC:
  2024. if (bp->dcbx_local_feat.pfc.enabled)
  2025. *flags |= DCB_FEATCFG_ENABLE;
  2026. if (bp->dcbx_error & (DCBX_LOCAL_PFC_ERROR |
  2027. DCBX_LOCAL_PFC_MISMATCH))
  2028. *flags |= DCB_FEATCFG_ERROR;
  2029. break;
  2030. case DCB_FEATCFG_ATTR_APP:
  2031. if (bp->dcbx_local_feat.app.enabled)
  2032. *flags |= DCB_FEATCFG_ENABLE;
  2033. if (bp->dcbx_error & (DCBX_LOCAL_APP_ERROR |
  2034. DCBX_LOCAL_APP_MISMATCH))
  2035. *flags |= DCB_FEATCFG_ERROR;
  2036. break;
  2037. default:
  2038. BNX2X_ERR("Non valid featrue-ID\n");
  2039. rval = -EINVAL;
  2040. break;
  2041. }
  2042. } else {
  2043. DP(BNX2X_MSG_DCB, "DCB disabled\n");
  2044. rval = -EINVAL;
  2045. }
  2046. return rval;
  2047. }
  2048. static u8 bnx2x_dcbnl_set_featcfg(struct net_device *netdev, int featid,
  2049. u8 flags)
  2050. {
  2051. struct bnx2x *bp = netdev_priv(netdev);
  2052. u8 rval = 0;
  2053. DP(BNX2X_MSG_DCB, "featid = %d flags = %02x\n", featid, flags);
  2054. /* ignore the 'advertise' flag */
  2055. if (bnx2x_dcbnl_set_valid(bp)) {
  2056. switch (featid) {
  2057. case DCB_FEATCFG_ATTR_PG:
  2058. bp->dcbx_config_params.admin_ets_enable =
  2059. flags & DCB_FEATCFG_ENABLE ? 1 : 0;
  2060. bp->dcbx_config_params.admin_ets_willing =
  2061. flags & DCB_FEATCFG_WILLING ? 1 : 0;
  2062. break;
  2063. case DCB_FEATCFG_ATTR_PFC:
  2064. bp->dcbx_config_params.admin_pfc_enable =
  2065. flags & DCB_FEATCFG_ENABLE ? 1 : 0;
  2066. bp->dcbx_config_params.admin_pfc_willing =
  2067. flags & DCB_FEATCFG_WILLING ? 1 : 0;
  2068. break;
  2069. case DCB_FEATCFG_ATTR_APP:
  2070. /* ignore enable, always enabled */
  2071. bp->dcbx_config_params.admin_app_priority_willing =
  2072. flags & DCB_FEATCFG_WILLING ? 1 : 0;
  2073. break;
  2074. default:
  2075. BNX2X_ERR("Non valid featrue-ID\n");
  2076. rval = -EINVAL;
  2077. break;
  2078. }
  2079. } else {
  2080. DP(BNX2X_MSG_DCB, "dcbnl call not valid\n");
  2081. rval = -EINVAL;
  2082. }
  2083. return rval;
  2084. }
  2085. static int bnx2x_peer_appinfo(struct net_device *netdev,
  2086. struct dcb_peer_app_info *info, u16* app_count)
  2087. {
  2088. int i;
  2089. struct bnx2x *bp = netdev_priv(netdev);
  2090. DP(BNX2X_MSG_DCB, "APP-INFO\n");
  2091. info->willing = (bp->dcbx_remote_flags & DCBX_APP_REM_WILLING) ?: 0;
  2092. info->error = (bp->dcbx_remote_flags & DCBX_APP_RX_ERROR) ?: 0;
  2093. *app_count = 0;
  2094. for (i = 0; i < DCBX_MAX_APP_PROTOCOL; i++)
  2095. if (bp->dcbx_remote_feat.app.app_pri_tbl[i].appBitfield &
  2096. DCBX_APP_ENTRY_VALID)
  2097. (*app_count)++;
  2098. return 0;
  2099. }
  2100. static int bnx2x_peer_apptable(struct net_device *netdev,
  2101. struct dcb_app *table)
  2102. {
  2103. int i, j;
  2104. struct bnx2x *bp = netdev_priv(netdev);
  2105. DP(BNX2X_MSG_DCB, "APP-TABLE\n");
  2106. for (i = 0, j = 0; i < DCBX_MAX_APP_PROTOCOL; i++) {
  2107. struct dcbx_app_priority_entry *ent =
  2108. &bp->dcbx_remote_feat.app.app_pri_tbl[i];
  2109. if (ent->appBitfield & DCBX_APP_ENTRY_VALID) {
  2110. table[j].selector = bnx2x_dcbx_dcbnl_app_idtype(ent);
  2111. table[j].priority = bnx2x_dcbx_dcbnl_app_up(ent);
  2112. table[j++].protocol = ent->app_id;
  2113. }
  2114. }
  2115. return 0;
  2116. }
  2117. static int bnx2x_cee_peer_getpg(struct net_device *netdev, struct cee_pg *pg)
  2118. {
  2119. int i;
  2120. struct bnx2x *bp = netdev_priv(netdev);
  2121. pg->willing = (bp->dcbx_remote_flags & DCBX_ETS_REM_WILLING) ?: 0;
  2122. for (i = 0; i < CEE_DCBX_MAX_PGS; i++) {
  2123. pg->pg_bw[i] =
  2124. DCBX_PG_BW_GET(bp->dcbx_remote_feat.ets.pg_bw_tbl, i);
  2125. pg->prio_pg[i] =
  2126. DCBX_PRI_PG_GET(bp->dcbx_remote_feat.ets.pri_pg_tbl, i);
  2127. }
  2128. return 0;
  2129. }
  2130. static int bnx2x_cee_peer_getpfc(struct net_device *netdev,
  2131. struct cee_pfc *pfc)
  2132. {
  2133. struct bnx2x *bp = netdev_priv(netdev);
  2134. pfc->tcs_supported = bp->dcbx_remote_feat.pfc.pfc_caps;
  2135. pfc->pfc_en = bp->dcbx_remote_feat.pfc.pri_en_bitmap;
  2136. return 0;
  2137. }
  2138. const struct dcbnl_rtnl_ops bnx2x_dcbnl_ops = {
  2139. .getstate = bnx2x_dcbnl_get_state,
  2140. .setstate = bnx2x_dcbnl_set_state,
  2141. .getpermhwaddr = bnx2x_dcbnl_get_perm_hw_addr,
  2142. .setpgtccfgtx = bnx2x_dcbnl_set_pg_tccfg_tx,
  2143. .setpgbwgcfgtx = bnx2x_dcbnl_set_pg_bwgcfg_tx,
  2144. .setpgtccfgrx = bnx2x_dcbnl_set_pg_tccfg_rx,
  2145. .setpgbwgcfgrx = bnx2x_dcbnl_set_pg_bwgcfg_rx,
  2146. .getpgtccfgtx = bnx2x_dcbnl_get_pg_tccfg_tx,
  2147. .getpgbwgcfgtx = bnx2x_dcbnl_get_pg_bwgcfg_tx,
  2148. .getpgtccfgrx = bnx2x_dcbnl_get_pg_tccfg_rx,
  2149. .getpgbwgcfgrx = bnx2x_dcbnl_get_pg_bwgcfg_rx,
  2150. .setpfccfg = bnx2x_dcbnl_set_pfc_cfg,
  2151. .getpfccfg = bnx2x_dcbnl_get_pfc_cfg,
  2152. .setall = bnx2x_dcbnl_set_all,
  2153. .getcap = bnx2x_dcbnl_get_cap,
  2154. .getnumtcs = bnx2x_dcbnl_get_numtcs,
  2155. .setnumtcs = bnx2x_dcbnl_set_numtcs,
  2156. .getpfcstate = bnx2x_dcbnl_get_pfc_state,
  2157. .setpfcstate = bnx2x_dcbnl_set_pfc_state,
  2158. .setapp = bnx2x_dcbnl_set_app_up,
  2159. .getdcbx = bnx2x_dcbnl_get_dcbx,
  2160. .setdcbx = bnx2x_dcbnl_set_dcbx,
  2161. .getfeatcfg = bnx2x_dcbnl_get_featcfg,
  2162. .setfeatcfg = bnx2x_dcbnl_set_featcfg,
  2163. .peer_getappinfo = bnx2x_peer_appinfo,
  2164. .peer_getapptable = bnx2x_peer_apptable,
  2165. .cee_peer_getpg = bnx2x_cee_peer_getpg,
  2166. .cee_peer_getpfc = bnx2x_cee_peer_getpfc,
  2167. };
  2168. #endif /* BCM_DCBNL */