bnx2x_dcb.c 72 KB

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