static u8 ixgbe_dcbnl_set_all(struct net_device *netdev) { struct ixgbe_adapter *adapter = netdev_priv(netdev); int ret; adapter->dcb_set_bitmap &= ~BIT_BCN; /* no set for BCN */ if (!adapter->dcb_set_bitmap) return 1; while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state)) msleep(1); if (netif_running(netdev)) ixgbe_down(adapter); ret = ixgbe_copy_dcb_cfg(&adapter->temp_dcb_cfg, &adapter->dcb_cfg, adapter->ring_feature[RING_F_DCB].indices); if (ret) { clear_bit(__IXGBE_RESETTING, &adapter->state); return ret; } if (netif_running(netdev)) ixgbe_up(adapter); adapter->dcb_set_bitmap = 0x00; clear_bit(__IXGBE_RESETTING, &adapter->state); return ret; }
static int ixgbe_dcb_slink_spd(struct sk_buff *skb, struct genl_info *info) { struct net_device *netdev = NULL; struct ixgbe_adapter *adapter = NULL; int ret = -EINVAL; u8 value; if (!info->attrs[DCB_A_IFNAME] || !info->attrs[DCB_A_LINK_SPD]) goto err; netdev = dev_get_by_name(&init_net, nla_data(info->attrs[DCB_A_IFNAME])); if (!netdev) goto err; ret = ixgbe_dcb_check_adapter(netdev); if (ret) goto err_out; else adapter = netdev_priv(netdev); value = nla_get_u8(info->attrs[DCB_A_LINK_SPD]); if (value > 9) { DPRINTK(DRV, ERR, "Value is not 0 thru 9, it is %d.\n", value); } else { if (!adapter->dcb_set_bitmap && ixgbe_copy_dcb_cfg(&adapter->dcb_cfg, &adapter->temp_dcb_cfg, adapter->ring_feature[RING_F_DCB].indices)) { ret = -EINVAL; goto err_out; } adapter->temp_dcb_cfg.link_speed = value; adapter->dcb_set_bitmap |= BIT_LINKSPEED; } ret = ixgbe_nl_reply(0, DCB_C_SLINK_SPD, DCB_A_LINK_SPD, info); if (ret) goto err_out; err_out: dev_put(netdev); err: return ret; }
static u8 ixgbe_dcbnl_set_all(struct net_device *netdev) { int ret = DCB_NO_HW_CHG; u8 prio_tc[8] = { 0 }; u8 i; dcb_set_bitmap |= ixgbe_copy_dcb_cfg(8); if (dcb_set_bitmap) return ret; ixgbe_dcb_unpack_map_cee(&dcb_cfg, 0, prio_tc); ixgbe_dcb_calculate_tc_credits_cee(&dcb_cfg,0); ixgbe_dcb_calculate_tc_credits_cee(&dcb_cfg,1); ixgbe_dcb_hw_config_cee(&dcb_cfg); if (dcb_set_bitmap & (BIT_PG_TX | BIT_PG_RX)) { for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) netdev_set_prio_tc_map(netdev, i, prio_tc[i]); ret = DCB_HW_CHG_RST; } if (dcb_set_bitmap & BIT_PFC) { if (dcb_cfg.pfc_mode_enable) { u8 pfc_en; ixgbe_dcb_unpack_pfc_cee(&dcb_cfg, prio_tc, &pfc_en); } if (ret != DCB_HW_CHG_RST) ret = DCB_HW_CHG; } if (dcb_set_bitmap & BIT_APP_UPCHG) { fcoe_up_set = fcoe_up; ret = DCB_HW_CHG_RST; } dcb_set_bitmap = 0x00; return ret; }
static u8 ixgbe_dcbnl_set_all(struct net_device *netdev) { struct ixgbe_adapter *adapter = netdev_priv(netdev); int ret; if (!adapter->dcb_set_bitmap) return DCB_NO_HW_CHG; if (adapter->dcb_set_bitmap & BIT_RESETLINK) { while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state)) msleep(1); if (adapter->dcb_set_bitmap & BIT_APP_UPCHG) { if (netif_running(netdev)) netdev->netdev_ops->ndo_stop(netdev); ixgbe_clear_interrupt_scheme(adapter); } else { if (netif_running(netdev)) ixgbe_down(adapter); } } ret = ixgbe_copy_dcb_cfg(&adapter->temp_dcb_cfg, &adapter->dcb_cfg, adapter->ring_feature[RING_F_DCB].indices); if (ret) { if (adapter->dcb_set_bitmap & BIT_RESETLINK) clear_bit(__IXGBE_RESETTING, &adapter->state); return DCB_NO_HW_CHG; } if (adapter->dcb_cfg.pfc_mode_enable) { if ((adapter->hw.mac.type != ixgbe_mac_82598EB) && (adapter->hw.fc.current_mode != ixgbe_fc_pfc)) adapter->last_lfc_mode = adapter->hw.fc.current_mode; adapter->hw.fc.requested_mode = ixgbe_fc_pfc; } else { if (adapter->hw.mac.type != ixgbe_mac_82598EB) adapter->hw.fc.requested_mode = adapter->last_lfc_mode; else adapter->hw.fc.requested_mode = ixgbe_fc_none; } if (adapter->dcb_set_bitmap & BIT_RESETLINK) { if (adapter->dcb_set_bitmap & BIT_APP_UPCHG) { ixgbe_init_interrupt_scheme(adapter); if (netif_running(netdev)) netdev->netdev_ops->ndo_open(netdev); } else { if (netif_running(netdev)) ixgbe_up(adapter); } ret = DCB_HW_CHG_RST; } else if (adapter->dcb_set_bitmap & BIT_PFC) { if (adapter->hw.mac.type == ixgbe_mac_82598EB) ixgbe_dcb_config_pfc_82598(&adapter->hw, &adapter->dcb_cfg); else if (adapter->hw.mac.type == ixgbe_mac_82599EB) ixgbe_dcb_config_pfc_82599(&adapter->hw, &adapter->dcb_cfg); ret = DCB_HW_CHG; } if (adapter->dcb_cfg.pfc_mode_enable) adapter->hw.fc.current_mode = ixgbe_fc_pfc; if (adapter->dcb_set_bitmap & BIT_RESETLINK) clear_bit(__IXGBE_RESETTING, &adapter->state); adapter->dcb_set_bitmap = 0x00; return ret; }
static u8 ixgbe_dcbnl_set_all(struct net_device *netdev) { struct ixgbe_adapter *adapter = netdev_priv(netdev); struct ixgbe_dcb_config *dcb_cfg = &adapter->dcb_cfg; struct ixgbe_hw *hw = &adapter->hw; int ret = DCB_NO_HW_CHG; int i; /* Fail command if not in CEE mode */ if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE)) return ret; adapter->dcb_set_bitmap |= ixgbe_copy_dcb_cfg(adapter, MAX_TRAFFIC_CLASS); if (!adapter->dcb_set_bitmap) return ret; if (adapter->dcb_set_bitmap & (BIT_PG_TX|BIT_PG_RX)) { u16 refill[MAX_TRAFFIC_CLASS], max[MAX_TRAFFIC_CLASS]; u8 bwg_id[MAX_TRAFFIC_CLASS], prio_type[MAX_TRAFFIC_CLASS]; /* Priority to TC mapping in CEE case default to 1:1 */ u8 prio_tc[MAX_USER_PRIORITY]; int max_frame = adapter->netdev->mtu + ETH_HLEN + ETH_FCS_LEN; #ifdef IXGBE_FCOE if (adapter->netdev->features & NETIF_F_FCOE_MTU) max_frame = max(max_frame, IXGBE_FCOE_JUMBO_FRAME_SIZE); #endif ixgbe_dcb_calculate_tc_credits(hw, dcb_cfg, max_frame, DCB_TX_CONFIG); ixgbe_dcb_calculate_tc_credits(hw, dcb_cfg, max_frame, DCB_RX_CONFIG); ixgbe_dcb_unpack_refill(dcb_cfg, DCB_TX_CONFIG, refill); ixgbe_dcb_unpack_max(dcb_cfg, max); ixgbe_dcb_unpack_bwgid(dcb_cfg, DCB_TX_CONFIG, bwg_id); ixgbe_dcb_unpack_prio(dcb_cfg, DCB_TX_CONFIG, prio_type); ixgbe_dcb_unpack_map(dcb_cfg, DCB_TX_CONFIG, prio_tc); ixgbe_dcb_hw_ets_config(hw, refill, max, bwg_id, prio_type, prio_tc); for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) netdev_set_prio_tc_map(netdev, i, prio_tc[i]); ret = DCB_HW_CHG_RST; } if (adapter->dcb_set_bitmap & BIT_PFC) { if (dcb_cfg->pfc_mode_enable) { u8 pfc_en; u8 prio_tc[MAX_USER_PRIORITY]; ixgbe_dcb_unpack_map(dcb_cfg, DCB_TX_CONFIG, prio_tc); ixgbe_dcb_unpack_pfc(dcb_cfg, &pfc_en); ixgbe_dcb_hw_pfc_config(hw, pfc_en, prio_tc); } else { hw->mac.ops.fc_enable(hw); } ixgbe_set_rx_drop_en(adapter); ret = DCB_HW_CHG; } #ifdef IXGBE_FCOE /* Reprogam FCoE hardware offloads when the traffic class * FCoE is using changes. This happens if the APP info * changes or the up2tc mapping is updated. */ if (adapter->dcb_set_bitmap & BIT_APP_UPCHG) { struct dcb_app app = { .selector = DCB_APP_IDTYPE_ETHTYPE, .protocol = ETH_P_FCOE, }; u8 up = dcb_getapp(netdev, &app); adapter->fcoe.up = ffs(up) - 1; ixgbe_dcbnl_devreset(netdev); ret = DCB_HW_CHG_RST; } #endif adapter->dcb_set_bitmap = 0x00; return ret; }
static u8 ixgbe_dcbnl_set_all(struct net_device *netdev) { struct ixgbe_adapter *adapter = netdev_priv(netdev); int ret; u8 prio_tc[IXGBE_DCB_MAX_USER_PRIORITY] = { 0 }; u8 pfc_en; /* Fail command if not in CEE mode */ if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE)) return 1; ret = ixgbe_copy_dcb_cfg(&adapter->temp_dcb_cfg, &adapter->dcb_cfg, IXGBE_DCB_MAX_TRAFFIC_CLASS); if (ret) return DCB_NO_HW_CHG; if (adapter->dcb_cfg.pfc_mode_enable) { switch (adapter->hw.mac.type) { case ixgbe_mac_82599EB: case ixgbe_mac_X540: if (adapter->hw.fc.current_mode != ixgbe_fc_pfc) adapter->last_lfc_mode = adapter->hw.fc.current_mode; break; default: break; } adapter->hw.fc.requested_mode = ixgbe_fc_pfc; } else { switch (adapter->hw.mac.type) { case ixgbe_mac_82598EB: adapter->hw.fc.requested_mode = ixgbe_fc_none; break; case ixgbe_mac_82599EB: case ixgbe_mac_X540: adapter->hw.fc.requested_mode = adapter->last_lfc_mode; break; default: break; } } ixgbe_dcb_unpack_map_cee(&adapter->dcb_cfg, IXGBE_DCB_TX_CONFIG, prio_tc); if (adapter->dcb_set_bitmap & (BIT_PG_TX | BIT_PG_RX)) { /* Priority to TC mapping in CEE case default to 1:1 */ int max_frame = adapter->netdev->mtu + ETH_HLEN + ETH_FCS_LEN; #ifdef HAVE_MQPRIO int i; #endif #ifdef IXGBE_FCOE if (adapter->netdev->features & NETIF_F_FCOE_MTU) max_frame = max(max_frame, IXGBE_FCOE_JUMBO_FRAME_SIZE); #endif ixgbe_dcb_calculate_tc_credits_cee(&adapter->hw, &adapter->dcb_cfg, max_frame, IXGBE_DCB_TX_CONFIG); ixgbe_dcb_calculate_tc_credits_cee(&adapter->hw, &adapter->dcb_cfg, max_frame, IXGBE_DCB_RX_CONFIG); ixgbe_dcb_hw_config_cee(&adapter->hw, &adapter->dcb_cfg); #ifdef HAVE_MQPRIO for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) netdev_set_prio_tc_map(netdev, i, prio_tc[i]); #endif /* HAVE_MQPRIO */ } if (adapter->dcb_set_bitmap & BIT_PFC) { ixgbe_dcb_unpack_pfc_cee(&adapter->dcb_cfg, prio_tc, &pfc_en); ixgbe_dcb_config_pfc(&adapter->hw, pfc_en, prio_tc); ret = DCB_HW_CHG; } if (adapter->dcb_cfg.pfc_mode_enable) adapter->hw.fc.current_mode = ixgbe_fc_pfc; #ifdef IXGBE_FCOE if ((adapter->fcoe.up_set != adapter->fcoe.up) || (adapter->dcb_set_bitmap & BIT_APP_UPCHG)) { adapter->fcoe.up_set = adapter->fcoe.up; ixgbe_dcbnl_devreset(netdev); } #endif /* IXGBE_FCOE */ adapter->dcb_set_bitmap = 0x00; return ret; }
static u8 ixgbe_dcbnl_set_all(struct net_device *netdev) { struct ixgbe_adapter *adapter = netdev_priv(netdev); int ret; if (!adapter->dcb_set_bitmap || !(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE)) return DCB_NO_HW_CHG; ret = ixgbe_copy_dcb_cfg(&adapter->temp_dcb_cfg, &adapter->dcb_cfg, MAX_TRAFFIC_CLASS); if (ret) return DCB_NO_HW_CHG; /* * Only take down the adapter if an app change occurred. FCoE * may shuffle tx rings in this case and this can not be done * without a reset currently. */ if (adapter->dcb_set_bitmap & BIT_APP_UPCHG) { while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state)) msleep(1); if (netif_running(netdev)) netdev->netdev_ops->ndo_stop(netdev); ixgbe_clear_interrupt_scheme(adapter); } if (adapter->dcb_cfg.pfc_mode_enable) { switch (adapter->hw.mac.type) { case ixgbe_mac_82599EB: case ixgbe_mac_X540: if (adapter->hw.fc.current_mode != ixgbe_fc_pfc) adapter->last_lfc_mode = adapter->hw.fc.current_mode; break; default: break; } adapter->hw.fc.requested_mode = ixgbe_fc_pfc; } else { switch (adapter->hw.mac.type) { case ixgbe_mac_82598EB: adapter->hw.fc.requested_mode = ixgbe_fc_none; break; case ixgbe_mac_82599EB: case ixgbe_mac_X540: adapter->hw.fc.requested_mode = adapter->last_lfc_mode; break; default: break; } } if (adapter->dcb_set_bitmap & BIT_APP_UPCHG) { ixgbe_init_interrupt_scheme(adapter); if (netif_running(netdev)) netdev->netdev_ops->ndo_open(netdev); ret = DCB_HW_CHG_RST; } if (adapter->dcb_set_bitmap & BIT_PFC) { u8 pfc_en; ixgbe_dcb_unpack_pfc(&adapter->dcb_cfg, &pfc_en); ixgbe_dcb_hw_pfc_config(&adapter->hw, pfc_en); ret = DCB_HW_CHG; } if (adapter->dcb_set_bitmap & (BIT_PG_TX|BIT_PG_RX)) { u16 refill[MAX_TRAFFIC_CLASS], max[MAX_TRAFFIC_CLASS]; u8 bwg_id[MAX_TRAFFIC_CLASS], prio_type[MAX_TRAFFIC_CLASS]; /* Priority to TC mapping in CEE case default to 1:1 */ u8 prio_tc[MAX_TRAFFIC_CLASS] = {0, 1, 2, 3, 4, 5, 6, 7}; int max_frame = adapter->netdev->mtu + ETH_HLEN + ETH_FCS_LEN; #ifdef CONFIG_FCOE if (adapter->netdev->features & NETIF_F_FCOE_MTU) max_frame = max(max_frame, IXGBE_FCOE_JUMBO_FRAME_SIZE); #endif ixgbe_dcb_calculate_tc_credits(&adapter->hw, &adapter->dcb_cfg, max_frame, DCB_TX_CONFIG); ixgbe_dcb_calculate_tc_credits(&adapter->hw, &adapter->dcb_cfg, max_frame, DCB_RX_CONFIG); ixgbe_dcb_unpack_refill(&adapter->dcb_cfg, DCB_TX_CONFIG, refill); ixgbe_dcb_unpack_max(&adapter->dcb_cfg, max); ixgbe_dcb_unpack_bwgid(&adapter->dcb_cfg, DCB_TX_CONFIG, bwg_id); ixgbe_dcb_unpack_prio(&adapter->dcb_cfg, DCB_TX_CONFIG, prio_type); ixgbe_dcb_hw_ets_config(&adapter->hw, refill, max, bwg_id, prio_type, prio_tc); } if (adapter->dcb_cfg.pfc_mode_enable) adapter->hw.fc.current_mode = ixgbe_fc_pfc; if (adapter->dcb_set_bitmap & BIT_APP_UPCHG) clear_bit(__IXGBE_RESETTING, &adapter->state); adapter->dcb_set_bitmap = 0x00; return ret; }
static u8 ixgbe_dcbnl_set_all(struct net_device *netdev) { struct ixgbe_adapter *adapter = netdev_priv(netdev); int ret, i; #ifdef IXGBE_FCOE struct dcb_app app = { .selector = DCB_APP_IDTYPE_ETHTYPE, .protocol = ETH_P_FCOE, }; u8 up = dcb_getapp(netdev, &app); #endif /* Fail command if not in CEE mode */ if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE)) return 1; ret = ixgbe_copy_dcb_cfg(&adapter->temp_dcb_cfg, &adapter->dcb_cfg, MAX_TRAFFIC_CLASS); if (ret) return DCB_NO_HW_CHG; #ifdef IXGBE_FCOE if (up && (up != (1 << adapter->fcoe.up))) adapter->dcb_set_bitmap |= BIT_APP_UPCHG; /* * Only take down the adapter if an app change occurred. FCoE * may shuffle tx rings in this case and this can not be done * without a reset currently. */ if (adapter->dcb_set_bitmap & BIT_APP_UPCHG) { while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state)) usleep_range(1000, 2000); adapter->fcoe.up = ffs(up) - 1; if (netif_running(netdev)) netdev->netdev_ops->ndo_stop(netdev); ixgbe_clear_interrupt_scheme(adapter); } #endif if (adapter->dcb_cfg.pfc_mode_enable) { switch (adapter->hw.mac.type) { case ixgbe_mac_82599EB: case ixgbe_mac_X540: if (adapter->hw.fc.current_mode != ixgbe_fc_pfc) adapter->last_lfc_mode = adapter->hw.fc.current_mode; break; default: break; } adapter->hw.fc.requested_mode = ixgbe_fc_pfc; } else { switch (adapter->hw.mac.type) { case ixgbe_mac_82598EB: adapter->hw.fc.requested_mode = ixgbe_fc_none; break; case ixgbe_mac_82599EB: case ixgbe_mac_X540: adapter->hw.fc.requested_mode = adapter->last_lfc_mode; break; default: break; } } #ifdef IXGBE_FCOE if (adapter->dcb_set_bitmap & BIT_APP_UPCHG) { ixgbe_init_interrupt_scheme(adapter); if (netif_running(netdev)) netdev->netdev_ops->ndo_open(netdev); ret = DCB_HW_CHG_RST; } #endif if (adapter->dcb_set_bitmap & (BIT_PG_TX|BIT_PG_RX)) { u16 refill[MAX_TRAFFIC_CLASS], max[MAX_TRAFFIC_CLASS]; u8 bwg_id[MAX_TRAFFIC_CLASS], prio_type[MAX_TRAFFIC_CLASS]; /* Priority to TC mapping in CEE case default to 1:1 */ u8 prio_tc[MAX_USER_PRIORITY]; int max_frame = adapter->netdev->mtu + ETH_HLEN + ETH_FCS_LEN; #ifdef IXGBE_FCOE if (adapter->netdev->features & NETIF_F_FCOE_MTU) max_frame = max(max_frame, IXGBE_FCOE_JUMBO_FRAME_SIZE); #endif ixgbe_dcb_calculate_tc_credits(&adapter->hw, &adapter->dcb_cfg, max_frame, DCB_TX_CONFIG); ixgbe_dcb_calculate_tc_credits(&adapter->hw, &adapter->dcb_cfg, max_frame, DCB_RX_CONFIG); ixgbe_dcb_unpack_refill(&adapter->dcb_cfg, DCB_TX_CONFIG, refill); ixgbe_dcb_unpack_max(&adapter->dcb_cfg, max); ixgbe_dcb_unpack_bwgid(&adapter->dcb_cfg, DCB_TX_CONFIG, bwg_id); ixgbe_dcb_unpack_prio(&adapter->dcb_cfg, DCB_TX_CONFIG, prio_type); ixgbe_dcb_unpack_map(&adapter->dcb_cfg, DCB_TX_CONFIG, prio_tc); ixgbe_dcb_hw_ets_config(&adapter->hw, refill, max, bwg_id, prio_type, prio_tc); for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) netdev_set_prio_tc_map(netdev, i, prio_tc[i]); } if (adapter->dcb_set_bitmap & BIT_PFC) { u8 pfc_en; u8 prio_tc[MAX_USER_PRIORITY]; ixgbe_dcb_unpack_map(&adapter->dcb_cfg, DCB_TX_CONFIG, prio_tc); ixgbe_dcb_unpack_pfc(&adapter->dcb_cfg, &pfc_en); ixgbe_dcb_hw_pfc_config(&adapter->hw, pfc_en, prio_tc); ret = DCB_HW_CHG; } if (adapter->dcb_cfg.pfc_mode_enable) adapter->hw.fc.current_mode = ixgbe_fc_pfc; if (adapter->dcb_set_bitmap & BIT_APP_UPCHG) clear_bit(__IXGBE_RESETTING, &adapter->state); adapter->dcb_set_bitmap = 0x00; return ret; }
static int ixgbe_dcb_pg_scfg(struct sk_buff *skb, struct genl_info *info, int dir) { struct net_device *netdev = NULL; struct ixgbe_adapter *adapter = NULL; struct tc_configuration *tc_config = NULL; struct tc_configuration *tc_tmpcfg = NULL; struct nlattr *pg_tb[IXGBE_DCB_PG_A_MAX + 1]; struct nlattr *param_tb[IXGBE_DCB_TC_A_PARAM_MAX + 1]; int i, ret, tc_max; u8 value; u8 changed = 0; if (!info->attrs[DCB_A_IFNAME] || !info->attrs[DCB_A_PG_CFG]) return -EINVAL; netdev = dev_get_by_name(&init_net, nla_data(info->attrs[DCB_A_IFNAME])); if (!netdev) return -EINVAL; ret = ixgbe_dcb_check_adapter(netdev); if (ret) goto err; else adapter = netdev_priv(netdev); ret = nla_parse_nested(pg_tb, IXGBE_DCB_PG_A_MAX, info->attrs[DCB_A_PG_CFG], dcb_pg_nest); if (ret) goto err; if (!adapter->dcb_set_bitmap && ixgbe_copy_dcb_cfg(&adapter->dcb_cfg, &adapter->temp_dcb_cfg, adapter->ring_feature[RING_F_DCB].indices)) goto err; tc_max = adapter->ring_feature[RING_F_DCB].indices; for (i = PG_A_TC_0; i < tc_max + PG_A_TC_0; i++) { if (!pg_tb[i]) continue; ret = nla_parse_nested(param_tb, IXGBE_DCB_TC_A_PARAM_MAX, pg_tb[i], dcb_tc_param_nest); if (ret) goto err; tc_config = &adapter->dcb_cfg.tc_config[i - PG_A_TC_0]; tc_tmpcfg = &adapter->temp_dcb_cfg.tc_config[i - PG_A_TC_0]; if (param_tb[TC_A_PARAM_STRICT_PRIO]) { value = nla_get_u8(param_tb[TC_A_PARAM_STRICT_PRIO]); tc_tmpcfg->path[dir].prio_type = value; if (tc_tmpcfg->path[dir].prio_type != tc_config->path[dir].prio_type) changed = 1; } if (param_tb[TC_A_PARAM_BW_GROUP_ID]) { value = nla_get_u8(param_tb[TC_A_PARAM_BW_GROUP_ID]); tc_tmpcfg->path[dir].bwg_id = value; if (tc_tmpcfg->path[dir].bwg_id != tc_config->path[dir].bwg_id) changed = 1; } if (param_tb[TC_A_PARAM_BW_PCT_IN_GROUP]) { value = nla_get_u8(param_tb[TC_A_PARAM_BW_PCT_IN_GROUP]); tc_tmpcfg->path[dir].bwg_percent = value; if (tc_tmpcfg->path[dir].bwg_percent != tc_config->path[dir].bwg_percent) changed = 1; } if (param_tb[TC_A_PARAM_UP_MAPPING]) { value = nla_get_u8(param_tb[TC_A_PARAM_UP_MAPPING]); tc_tmpcfg->path[dir].up_to_tc_bitmap = value; if (tc_tmpcfg->path[dir].up_to_tc_bitmap != tc_config->path[dir].up_to_tc_bitmap) changed = 1; } } for (i = PG_A_BWG_0; i < PG_A_BWG_MAX; i++) { if (!pg_tb[i]) continue; value = nla_get_u8(pg_tb[i]); adapter->temp_dcb_cfg.bw_percentage[dir][i-PG_A_BWG_0] = value; if (adapter->temp_dcb_cfg.bw_percentage[dir][i-PG_A_BWG_0] != adapter->dcb_cfg.bw_percentage[dir][i-PG_A_BWG_0]) changed = 1; } adapter->temp_dcb_cfg.round_robin_enable = false; if (changed) { if (dir == DCB_TX_CONFIG) adapter->dcb_set_bitmap |= BIT_PG_TX; else adapter->dcb_set_bitmap |= BIT_PG_RX; adapter->dcb_set_bitmap |= BIT_RESETLINK; } ret = ixgbe_nl_reply(0, (dir? DCB_C_PGRX_SCFG : DCB_C_PGTX_SCFG), DCB_A_PG_CFG, info); if (ret) goto err; err: dev_put(netdev); return ret; }
static int ixgbe_dcb_set_all(struct sk_buff *skb, struct genl_info *info) { struct net_device *netdev = NULL; struct ixgbe_adapter *adapter = NULL; int ret = -ENOMEM; u8 value; u8 retval = 0; if (!info->attrs[DCB_A_IFNAME] || !info->attrs[DCB_A_SET_ALL]) goto err; netdev = dev_get_by_name(&init_net, nla_data(info->attrs[DCB_A_IFNAME])); if (!netdev) goto err; ret = ixgbe_dcb_check_adapter(netdev); if (ret) goto err_out; else adapter = netdev_priv(netdev); if (!(adapter->flags & IXGBE_FLAG_DCA_CAPABLE)) { ret = -EINVAL; goto err_out; } value = nla_get_u8(info->attrs[DCB_A_SET_ALL]); if ((value & 1) != value) { DPRINTK(DRV, ERR, "Value is not 1 or 0, it is %d.\n", value); } else { if (!adapter->dcb_set_bitmap) { retval = 1; goto out; } while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state)) msleep(1); ret = ixgbe_copy_dcb_cfg(&adapter->temp_dcb_cfg, &adapter->dcb_cfg, adapter->ring_feature[RING_F_DCB].indices); if (ret) { clear_bit(__IXGBE_RESETTING, &adapter->state); goto err_out; } ixgbe_down(adapter); ixgbe_up(adapter); adapter->dcb_set_bitmap = 0x00; clear_bit(__IXGBE_RESETTING, &adapter->state); } out: ret = ixgbe_nl_reply(retval, DCB_C_SET_ALL, DCB_A_SET_ALL, info); if (ret) goto err_out; err_out: dev_put(netdev); err: return ret; }
static u8 ixgbe_dcbnl_set_all(struct net_device *netdev) { struct ixgbe_adapter *adapter = netdev_priv(netdev); bool do_reset; int ret; if (!adapter->dcb_set_bitmap) return DCB_NO_HW_CHG; ret = ixgbe_copy_dcb_cfg(&adapter->temp_dcb_cfg, &adapter->dcb_cfg, adapter->ring_feature[RING_F_DCB].indices); if (ret) return DCB_NO_HW_CHG; /* Only take down the adapter if the configuration change * requires a reset. */ do_reset = adapter->dcb_set_bitmap & (BIT_RESETLINK | BIT_APP_UPCHG); if (do_reset) { while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state)) msleep(1); if (adapter->dcb_set_bitmap & BIT_APP_UPCHG) { if (netif_running(netdev)) #ifdef HAVE_NET_DEVICE_OPS netdev->netdev_ops->ndo_stop(netdev); #else netdev->stop(netdev); #endif ixgbe_clear_interrupt_scheme(adapter); } else { if (netif_running(netdev)) ixgbe_down(adapter); } } if (adapter->dcb_cfg.pfc_mode_enable) { switch (adapter->hw.mac.type) { case ixgbe_mac_82599EB: case ixgbe_mac_X540: if (adapter->hw.fc.current_mode != ixgbe_fc_pfc) adapter->last_lfc_mode = adapter->hw.fc.current_mode; break; default: break; } adapter->hw.fc.requested_mode = ixgbe_fc_pfc; } else { switch (adapter->hw.mac.type) { case ixgbe_mac_82598EB: adapter->hw.fc.requested_mode = ixgbe_fc_none; break; case ixgbe_mac_82599EB: case ixgbe_mac_X540: adapter->hw.fc.requested_mode = adapter->last_lfc_mode; break; default: break; } } if (do_reset) { if (adapter->dcb_set_bitmap & BIT_APP_UPCHG) { ixgbe_init_interrupt_scheme(adapter); if (netif_running(netdev)) #ifdef HAVE_NET_DEVICE_OPS netdev->netdev_ops->ndo_open(netdev); #else netdev->open(netdev); #endif } else { if (netif_running(netdev)) ixgbe_up(adapter); } ret = DCB_HW_CHG_RST; } else if (adapter->dcb_set_bitmap & BIT_PFC) { if (adapter->hw.mac.type == ixgbe_mac_82598EB) ixgbe_dcb_config_pfc_82598(&adapter->hw, &adapter->dcb_cfg); else if (adapter->hw.mac.type == ixgbe_mac_82599EB) ixgbe_dcb_config_pfc_82599(&adapter->hw, &adapter->dcb_cfg); ret = DCB_HW_CHG; } if (adapter->dcb_cfg.pfc_mode_enable) adapter->hw.fc.current_mode = ixgbe_fc_pfc; if (do_reset) clear_bit(__IXGBE_RESETTING, &adapter->state); adapter->dcb_set_bitmap = 0x00; return ret; }
static int ixgbe_dcb_spfccfg(struct sk_buff *skb, struct genl_info *info) { struct nlattr *tb[IXGBE_DCB_PFC_A_UP_MAX + 1]; struct net_device *netdev = NULL; struct ixgbe_adapter *adapter = NULL; int i, ret = -ENOMEM; u8 setting; u8 changed = 0; netdev = dev_get_by_name(&init_net, nla_data(info->attrs[DCB_A_IFNAME])); if (!netdev) return -EINVAL; adapter = netdev_priv(netdev); if (!info->attrs[DCB_A_IFNAME] || !info->attrs[DCB_A_PFC_CFG]) return -EINVAL; ret = ixgbe_dcb_check_adapter(netdev); if (ret) goto err; else adapter = netdev_priv(netdev); ret = nla_parse_nested(tb, IXGBE_DCB_PFC_A_UP_MAX, info->attrs[DCB_A_PFC_CFG], dcb_pfc_up_nest); if (ret) goto err; if (!adapter->dcb_set_bitmap && ixgbe_copy_dcb_cfg(&adapter->dcb_cfg, &adapter->temp_dcb_cfg, adapter->ring_feature[RING_F_DCB].indices)) { ret = -EINVAL; goto err; } for (i = PFC_A_UP_0; i < PFC_A_UP_MAX; i++) { if (!tb[i]) continue; setting = nla_get_u8(tb[i]); adapter->temp_dcb_cfg.tc_config[i-PFC_A_UP_0].dcb_pfc = setting; if (adapter->temp_dcb_cfg.tc_config[i-PFC_A_UP_0].dcb_pfc != adapter->dcb_cfg.tc_config[i-PFC_A_UP_0].dcb_pfc) changed = 1; } if (changed) adapter->dcb_set_bitmap |= BIT_PFC; ret = ixgbe_nl_reply(0, DCB_C_PFC_SCFG, DCB_A_PFC_CFG, info); if (ret) goto err; err: dev_put(netdev); return ret; }
static u8 ixgbe_dcbnl_set_all(struct net_device *netdev) { struct ixgbe_adapter *adapter = netdev_priv(netdev); struct ixgbe_dcb_config *dcb_cfg = &adapter->dcb_cfg; struct ixgbe_hw *hw = &adapter->hw; int ret = DCB_NO_HW_CHG; u8 prio_tc[IXGBE_DCB_MAX_USER_PRIORITY] = { 0 }; /* Fail command if not in CEE mode */ if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE)) return ret; adapter->dcb_set_bitmap |= ixgbe_copy_dcb_cfg(adapter, IXGBE_DCB_MAX_TRAFFIC_CLASS); if (!adapter->dcb_set_bitmap) return ret; ixgbe_dcb_unpack_map_cee(dcb_cfg, IXGBE_DCB_TX_CONFIG, prio_tc); if (adapter->dcb_set_bitmap & (BIT_PG_TX | BIT_PG_RX)) { /* Priority to TC mapping in CEE case default to 1:1 */ int max_frame = adapter->netdev->mtu + ETH_HLEN + ETH_FCS_LEN; #ifdef HAVE_MQPRIO int i; #endif #ifdef IXGBE_FCOE if (adapter->netdev->features & NETIF_F_FCOE_MTU) max_frame = max(max_frame, IXGBE_FCOE_JUMBO_FRAME_SIZE); #endif ixgbe_dcb_calculate_tc_credits_cee(hw, dcb_cfg, max_frame, IXGBE_DCB_TX_CONFIG); ixgbe_dcb_calculate_tc_credits_cee(hw, dcb_cfg, max_frame, IXGBE_DCB_RX_CONFIG); ixgbe_dcb_hw_config_cee(hw, dcb_cfg); #ifdef HAVE_MQPRIO for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) netdev_set_prio_tc_map(netdev, i, prio_tc[i]); #endif /* HAVE_MQPRIO */ ret = DCB_HW_CHG_RST; } if (adapter->dcb_set_bitmap & BIT_PFC) { if (dcb_cfg->pfc_mode_enable) { u8 pfc_en; ixgbe_dcb_unpack_pfc_cee(dcb_cfg, prio_tc, &pfc_en); ixgbe_dcb_config_pfc(hw, pfc_en, prio_tc); } else { hw->mac.ops.fc_enable(hw); } ixgbe_set_rx_drop_en(adapter); if (ret != DCB_HW_CHG_RST) ret = DCB_HW_CHG; } #ifdef IXGBE_FCOE /* Reprogam FCoE hardware offloads when the traffic class * FCoE is using changes. This happens if the APP info * changes or the up2tc mapping is updated. */ if (adapter->dcb_set_bitmap & BIT_APP_UPCHG) { adapter->fcoe.up_set = adapter->fcoe.up; ixgbe_dcbnl_devreset(netdev); ret = DCB_HW_CHG_RST; } #endif /* IXGBE_FCOE */ adapter->dcb_set_bitmap = 0x00; return ret; }