ethdev: new Rx/Tx offloads API
[dpdk.git] / drivers / net / ixgbe / ixgbe_rxtx.c
index aed3f5a..3e13d26 100644 (file)
@@ -2448,22 +2448,6 @@ ixgbe_get_tx_port_offloads(struct rte_eth_dev *dev)
        return tx_offload_capa;
 }
 
-static int
-ixgbe_check_tx_queue_offloads(struct rte_eth_dev *dev, uint64_t requested)
-{
-       uint64_t port_offloads = dev->data->dev_conf.txmode.offloads;
-       uint64_t queue_supported = ixgbe_get_tx_queue_offloads(dev);
-       uint64_t port_supported = ixgbe_get_tx_port_offloads(dev);
-
-       if ((requested & (queue_supported | port_supported)) != requested)
-               return 0;
-
-       if ((port_offloads ^ requested) & port_supported)
-               return 0;
-
-       return 1;
-}
-
 int __attribute__((cold))
 ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
                         uint16_t queue_idx,
@@ -2475,25 +2459,12 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
        struct ixgbe_tx_queue *txq;
        struct ixgbe_hw     *hw;
        uint16_t tx_rs_thresh, tx_free_thresh;
+       uint64_t offloads;
 
        PMD_INIT_FUNC_TRACE();
        hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-       /*
-        * Don't verify port offloads for application which
-        * use the old API.
-        */
-       if (!ixgbe_check_tx_queue_offloads(dev, tx_conf->offloads)) {
-               PMD_INIT_LOG(ERR, "%p: Tx queue offloads 0x%" PRIx64
-                       " don't match port offloads 0x%" PRIx64
-                       " or supported queue offloads 0x%" PRIx64
-                       " or supported port offloads 0x%" PRIx64,
-                       (void *)dev, tx_conf->offloads,
-                       dev->data->dev_conf.txmode.offloads,
-                       ixgbe_get_tx_queue_offloads(dev),
-                       ixgbe_get_tx_port_offloads(dev));
-               return -ENOTSUP;
-       }
+       offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
 
        /*
         * Validate number of transmit descriptors.
@@ -2620,8 +2591,7 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
        txq->reg_idx = (uint16_t)((RTE_ETH_DEV_SRIOV(dev).active == 0) ?
                queue_idx : RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx + queue_idx);
        txq->port_id = dev->data->port_id;
-       txq->txq_flags = tx_conf->txq_flags;
-       txq->offloads = tx_conf->offloads;
+       txq->offloads = offloads;
        txq->ops = &def_txq_ops;
        txq->tx_deferred_start = tx_conf->tx_deferred_start;
 #ifdef RTE_LIBRTE_SECURITY
@@ -2915,22 +2885,6 @@ ixgbe_get_rx_port_offloads(struct rte_eth_dev *dev)
        return offloads;
 }
 
-static int
-ixgbe_check_rx_queue_offloads(struct rte_eth_dev *dev, uint64_t requested)
-{
-       uint64_t port_offloads = dev->data->dev_conf.rxmode.offloads;
-       uint64_t queue_supported = ixgbe_get_rx_queue_offloads(dev);
-       uint64_t port_supported = ixgbe_get_rx_port_offloads(dev);
-
-       if ((requested & (queue_supported | port_supported)) != requested)
-               return 0;
-
-       if ((port_offloads ^ requested) & port_supported)
-               return 0;
-
-       return 1;
-}
-
 int __attribute__((cold))
 ixgbe_dev_rx_queue_setup(struct rte_eth_dev *dev,
                         uint16_t queue_idx,
@@ -2945,21 +2899,12 @@ ixgbe_dev_rx_queue_setup(struct rte_eth_dev *dev,
        uint16_t len;
        struct ixgbe_adapter *adapter =
                (struct ixgbe_adapter *)dev->data->dev_private;
+       uint64_t offloads;
 
        PMD_INIT_FUNC_TRACE();
        hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-       if (!ixgbe_check_rx_queue_offloads(dev, rx_conf->offloads)) {
-               PMD_INIT_LOG(ERR, "%p: Rx queue offloads 0x%" PRIx64
-                       " don't match port offloads 0x%" PRIx64
-                       " or supported port offloads 0x%" PRIx64
-                       " or supported queue offloads 0x%" PRIx64,
-                       (void *)dev, rx_conf->offloads,
-                       dev->data->dev_conf.rxmode.offloads,
-                       ixgbe_get_rx_port_offloads(dev),
-                       ixgbe_get_rx_queue_offloads(dev));
-               return -ENOTSUP;
-       }
+       offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;
 
        /*
         * Validate number of receive descriptors.
@@ -2994,7 +2939,7 @@ ixgbe_dev_rx_queue_setup(struct rte_eth_dev *dev,
                DEV_RX_OFFLOAD_CRC_STRIP) ? 0 : ETHER_CRC_LEN);
        rxq->drop_en = rx_conf->rx_drop_en;
        rxq->rx_deferred_start = rx_conf->rx_deferred_start;
-       rxq->offloads = rx_conf->offloads;
+       rxq->offloads = offloads;
 
        /*
         * The packet type in RX descriptor is different for different NICs.
@@ -4842,7 +4787,8 @@ ixgbe_set_rsc(struct rte_eth_dev *dev)
                 * at most 500us latency for a single RSC aggregation.
                 */
                eitr &= ~IXGBE_EITR_ITR_INT_MASK;
-               eitr |= IXGBE_EITR_INTERVAL_US(500) | IXGBE_EITR_CNT_WDIS;
+               eitr |= IXGBE_EITR_INTERVAL_US(IXGBE_QUEUE_ITR_INTERVAL_DEFAULT);
+               eitr |= IXGBE_EITR_CNT_WDIS;
 
                IXGBE_WRITE_REG(hw, IXGBE_SRRCTL(rxq->reg_idx), srrctl);
                IXGBE_WRITE_REG(hw, IXGBE_RSCCTL(rxq->reg_idx), rscctl);
@@ -5441,7 +5387,6 @@ ixgbe_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
 
        qinfo->conf.tx_free_thresh = txq->tx_free_thresh;
        qinfo->conf.tx_rs_thresh = txq->tx_rs_thresh;
-       qinfo->conf.txq_flags = txq->txq_flags;
        qinfo->conf.offloads = txq->offloads;
        qinfo->conf.tx_deferred_start = txq->tx_deferred_start;
 }
@@ -5675,6 +5620,40 @@ ixgbevf_dev_rxtx_start(struct rte_eth_dev *dev)
        }
 }
 
+int
+ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out,
+                   const struct rte_flow_action_rss *in)
+{
+       if (in->key_len > RTE_DIM(out->key) ||
+           in->queue_num > RTE_DIM(out->queue))
+               return -EINVAL;
+       out->conf = (struct rte_flow_action_rss){
+               .func = in->func,
+               .level = in->level,
+               .types = in->types,
+               .key_len = in->key_len,
+               .queue_num = in->queue_num,
+               .key = memcpy(out->key, in->key, in->key_len),
+               .queue = memcpy(out->queue, in->queue,
+                               sizeof(*in->queue) * in->queue_num),
+       };
+       return 0;
+}
+
+int
+ixgbe_action_rss_same(const struct rte_flow_action_rss *comp,
+                     const struct rte_flow_action_rss *with)
+{
+       return (comp->func == with->func &&
+               comp->level == with->level &&
+               comp->types == with->types &&
+               comp->key_len == with->key_len &&
+               comp->queue_num == with->queue_num &&
+               !memcmp(comp->key, with->key, with->key_len) &&
+               !memcmp(comp->queue, with->queue,
+                       sizeof(*with->queue) * with->queue_num));
+}
+
 int
 ixgbe_config_rss_filter(struct rte_eth_dev *dev,
                struct ixgbe_rte_flow_rss_conf *conf, bool add)
@@ -5685,7 +5664,12 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev,
        uint16_t j;
        uint16_t sp_reta_size;
        uint32_t reta_reg;
-       struct rte_eth_rss_conf rss_conf = conf->rss_conf;
+       struct rte_eth_rss_conf rss_conf = {
+               .rss_key = conf->conf.key_len ?
+                       (void *)(uintptr_t)conf->conf.key : NULL,
+               .rss_key_len = conf->conf.key_len,
+               .rss_hf = conf->conf.types,
+       };
        struct ixgbe_filter_info *filter_info =
                IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
 
@@ -5695,8 +5679,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev,
        sp_reta_size = ixgbe_reta_size_get(hw->mac.type);
 
        if (!add) {
-               if (memcmp(conf, &filter_info->rss_info,
-                       sizeof(struct ixgbe_rte_flow_rss_conf)) == 0) {
+               if (ixgbe_action_rss_same(&filter_info->rss_info.conf,
+                                         &conf->conf)) {
                        ixgbe_rss_disable(dev);
                        memset(&filter_info->rss_info, 0,
                                sizeof(struct ixgbe_rte_flow_rss_conf));
@@ -5705,7 +5689,7 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev,
                return -EINVAL;
        }
 
-       if (filter_info->rss_info.num)
+       if (filter_info->rss_info.conf.queue_num)
                return -EINVAL;
        /* Fill in redirection table
         * The byte-swap is needed because NIC registers are in
@@ -5715,9 +5699,9 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev,
        for (i = 0, j = 0; i < sp_reta_size; i++, j++) {
                reta_reg = ixgbe_reta_reg_get(hw->mac.type, i);
 
-               if (j == conf->num)
+               if (j == conf->conf.queue_num)
                        j = 0;
-               reta = (reta << 8) | conf->queue[j];
+               reta = (reta << 8) | conf->conf.queue[j];
                if ((i & 3) == 3)
                        IXGBE_WRITE_REG(hw, reta_reg,
                                        rte_bswap32(reta));
@@ -5734,8 +5718,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev,
                rss_conf.rss_key = rss_intel_key; /* Default hash key */
        ixgbe_hw_rss_hash_set(hw, &rss_conf);
 
-       rte_memcpy(&filter_info->rss_info,
-               conf, sizeof(struct ixgbe_rte_flow_rss_conf));
+       if (ixgbe_rss_conf_init(&filter_info->rss_info, &conf->conf))
+               return -EINVAL;
 
        return 0;
 }