bnx2x_dcb.c 72 KB

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