ixgbe: IEEE 802.1Qaz, implement priority assignment table
[deliverable/linux.git] / drivers / net / ixgbe / ixgbe_dcb_nl.c
index d4b2914376db8c7d2a8ea9dfe44b31579a16b324..fec4c724c37ad99775b26a9998495079672b2fb2 100644 (file)
@@ -129,7 +129,6 @@ static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state)
                        netdev->netdev_ops->ndo_stop(netdev);
                ixgbe_clear_interrupt_scheme(adapter);
 
-               adapter->flags &= ~IXGBE_FLAG_RSS_ENABLED;
                switch (adapter->hw.mac.type) {
                case ixgbe_mac_82598EB:
                        adapter->last_lfc_mode = adapter->hw.fc.current_mode;
@@ -145,6 +144,9 @@ static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state)
                }
 
                adapter->flags |= IXGBE_FLAG_DCB_ENABLED;
+               if (!netdev_get_num_tc(netdev))
+                       ixgbe_setup_tc(netdev, MAX_TRAFFIC_CLASS);
+
                ixgbe_init_interrupt_scheme(adapter);
                if (netif_running(netdev))
                        netdev->netdev_ops->ndo_open(netdev);
@@ -159,7 +161,6 @@ static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state)
                        adapter->temp_dcb_cfg.pfc_mode_enable = false;
                        adapter->dcb_cfg.pfc_mode_enable = false;
                        adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED;
-                       adapter->flags |= IXGBE_FLAG_RSS_ENABLED;
                        switch (adapter->hw.mac.type) {
                        case ixgbe_mac_82599EB:
                        case ixgbe_mac_X540:
@@ -169,6 +170,8 @@ static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state)
                                break;
                        }
 
+                       ixgbe_setup_tc(netdev, 0);
+
                        ixgbe_init_interrupt_scheme(adapter);
                        if (netif_running(netdev))
                                netdev->netdev_ops->ndo_open(netdev);
@@ -351,7 +354,7 @@ static u8 ixgbe_dcbnl_set_all(struct net_device *netdev)
                return DCB_NO_HW_CHG;
 
        ret = ixgbe_copy_dcb_cfg(&adapter->temp_dcb_cfg, &adapter->dcb_cfg,
-                                adapter->ring_feature[RING_F_DCB].indices);
+                                MAX_TRAFFIC_CLASS);
 
        if (ret)
                return DCB_NO_HW_CHG;
@@ -413,6 +416,8 @@ static u8 ixgbe_dcbnl_set_all(struct net_device *netdev)
        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
@@ -434,7 +439,7 @@ static u8 ixgbe_dcbnl_set_all(struct net_device *netdev)
                                      DCB_TX_CONFIG, prio_type);
 
                ixgbe_dcb_hw_ets_config(&adapter->hw, refill, max,
-                                       bwg_id, prio_type);
+                                       bwg_id, prio_type, prio_tc);
        }
 
        if (adapter->dcb_cfg.pfc_mode_enable)
@@ -639,8 +644,10 @@ static int ixgbe_dcbnl_ieee_setets(struct net_device *dev,
 {
        struct ixgbe_adapter *adapter = netdev_priv(dev);
        __u16 refill[IEEE_8021QAZ_MAX_TCS], max[IEEE_8021QAZ_MAX_TCS];
+       __u8 prio_type[IEEE_8021QAZ_MAX_TCS];
        int max_frame = dev->mtu + ETH_HLEN + ETH_FCS_LEN;
-       int err;
+       int i, err;
+       __u64 *p = (__u64 *) ets->prio_tc;
        /* naively give each TC a bwg to map onto CEE hardware */
        __u8 bwg_id[IEEE_8021QAZ_MAX_TCS] = {0, 1, 2, 3, 4, 5, 6, 7};
 
@@ -656,9 +663,33 @@ static int ixgbe_dcbnl_ieee_setets(struct net_device *dev,
 
        memcpy(adapter->ixgbe_ieee_ets, ets, sizeof(*adapter->ixgbe_ieee_ets));
 
+       /* Map TSA onto CEE prio type */
+       for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
+               switch (ets->tc_tsa[i]) {
+               case IEEE_8021QAZ_TSA_STRICT:
+                       prio_type[i] = 2;
+                       break;
+               case IEEE_8021QAZ_TSA_ETS:
+                       prio_type[i] = 0;
+                       break;
+               default:
+                       /* Hardware only supports priority strict or
+                        * ETS transmission selection algorithms if
+                        * we receive some other value from dcbnl
+                        * throw an error
+                        */
+                       return -EINVAL;
+               }
+       }
+
+       if (*p)
+               ixgbe_dcbnl_set_state(dev, 1);
+       else
+               ixgbe_dcbnl_set_state(dev, 0);
+
        ixgbe_ieee_credits(ets->tc_tx_bw, refill, max, max_frame);
        err = ixgbe_dcb_hw_ets_config(&adapter->hw, refill, max,
-                                     bwg_id, ets->tc_tsa);
+                                     bwg_id, prio_type, ets->prio_tc);
        return err;
 }
 
This page took 0.025567 seconds and 5 git commands to generate.