bnx2x_dcb.c 73 KB

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