提交 dd54a1ad 编写于 作者: J Jesse Brandeburg 提交者: Jeff Kirsher

i40e: refactor DCB function

This is a simple refactor suggested by the community
to change a multi-level if statement into a switch.

Change-ID: I831cf3c40426022220aa9b43990022d22dfd50db
Signed-off-by: NJesse Brandeburg <jesse.brandeburg@intel.com>
Acked-by: NShannon Nelson <shannon.nelson@intel.com>
Tested-by: NAndrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: NJeff Kirsher <jeffrey.t.kirsher@intel.com>
上级 07f169c3
...@@ -380,17 +380,20 @@ static void i40e_parse_cee_app_tlv(struct i40e_cee_feat_tlv *tlv, ...@@ -380,17 +380,20 @@ static void i40e_parse_cee_app_tlv(struct i40e_cee_feat_tlv *tlv,
{ {
u16 length, typelength, offset = 0; u16 length, typelength, offset = 0;
struct i40e_cee_app_prio *app; struct i40e_cee_app_prio *app;
u8 i, up, selector; u8 i;
typelength = ntohs(tlv->hdr.typelen); typelength = ntohs(tlv->hdr.typelen);
length = (u16)((typelength & I40E_LLDP_TLV_LEN_MASK) >> length = (u16)((typelength & I40E_LLDP_TLV_LEN_MASK) >>
I40E_LLDP_TLV_LEN_SHIFT); I40E_LLDP_TLV_LEN_SHIFT);
dcbcfg->numapps = length / sizeof(*app); dcbcfg->numapps = length / sizeof(*app);
if (!dcbcfg->numapps) if (!dcbcfg->numapps)
return; return;
for (i = 0; i < dcbcfg->numapps; i++) { for (i = 0; i < dcbcfg->numapps; i++) {
u8 up, selector;
app = (struct i40e_cee_app_prio *)(tlv->tlvinfo + offset); app = (struct i40e_cee_app_prio *)(tlv->tlvinfo + offset);
for (up = 0; up < I40E_MAX_USER_PRIORITY; up++) { for (up = 0; up < I40E_MAX_USER_PRIORITY; up++) {
if (app->prio_map & BIT(up)) if (app->prio_map & BIT(up))
...@@ -400,13 +403,17 @@ static void i40e_parse_cee_app_tlv(struct i40e_cee_feat_tlv *tlv, ...@@ -400,13 +403,17 @@ static void i40e_parse_cee_app_tlv(struct i40e_cee_feat_tlv *tlv,
/* Get Selector from lower 2 bits, and convert to IEEE */ /* Get Selector from lower 2 bits, and convert to IEEE */
selector = (app->upper_oui_sel & I40E_CEE_APP_SELECTOR_MASK); selector = (app->upper_oui_sel & I40E_CEE_APP_SELECTOR_MASK);
if (selector == I40E_CEE_APP_SEL_ETHTYPE) switch (selector) {
case I40E_CEE_APP_SEL_ETHTYPE:
dcbcfg->app[i].selector = I40E_APP_SEL_ETHTYPE; dcbcfg->app[i].selector = I40E_APP_SEL_ETHTYPE;
else if (selector == I40E_CEE_APP_SEL_TCPIP) break;
case I40E_CEE_APP_SEL_TCPIP:
dcbcfg->app[i].selector = I40E_APP_SEL_TCPIP; dcbcfg->app[i].selector = I40E_APP_SEL_TCPIP;
else break;
default:
/* Keep selector as it is for unknown types */ /* Keep selector as it is for unknown types */
dcbcfg->app[i].selector = selector; dcbcfg->app[i].selector = selector;
}
dcbcfg->app[i].protocolid = ntohs(app->protocol); dcbcfg->app[i].protocolid = ntohs(app->protocol);
/* Move to next app */ /* Move to next app */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册