i40e: advertise outer IPv4 checksum capability
[dpdk.git] / lib / librte_pmd_i40e / i40e_pf.c
index f4b4f2d..cbb2dcc 100644 (file)
@@ -56,6 +56,8 @@
 #include "i40e_rxtx.h"
 #include "i40e_pf.h"
 
+#define I40E_CFG_CRCSTRIP_DEFAULT 1
+
 static int
 i40e_pf_host_switch_queues(struct i40e_pf_vf *vf,
                           struct i40e_virtchnl_queue_select *qsel,
@@ -325,7 +327,8 @@ send_msg:
 static int
 i40e_pf_host_hmc_config_rxq(struct i40e_hw *hw,
                            struct i40e_pf_vf *vf,
-                           struct i40e_virtchnl_rxq_info *rxq)
+                           struct i40e_virtchnl_rxq_info *rxq,
+                           uint8_t crcstrip)
 {
        int err = I40E_SUCCESS;
        struct i40e_hmc_obj_rxq rx_ctx;
@@ -354,7 +357,7 @@ i40e_pf_host_hmc_config_rxq(struct i40e_hw *hw,
        rx_ctx.tphdata_ena = 1;
        rx_ctx.tphhead_ena = 1;
        rx_ctx.lrxqthresh = 2;
-       rx_ctx.crcstrip = 1;
+       rx_ctx.crcstrip = crcstrip;
        rx_ctx.l2tsel = 1;
        rx_ctx.prefena = 1;
 
@@ -418,9 +421,11 @@ i40e_pf_host_process_cmd_config_vsi_queues(struct i40e_pf_vf *vf,
        struct i40e_virtchnl_queue_pair_info *vc_qpi;
        int i, ret = I40E_SUCCESS;
 
-       if (msg == NULL || msglen <= sizeof(*vc_vqci) ||
-               vc_vqci->num_queue_pairs > vsi->nb_qps) {
-               PMD_DRV_LOG(ERR, "vsi_queue_config_info argument wrong");
+       if (!msg || vc_vqci->num_queue_pairs > vsi->nb_qps ||
+               vc_vqci->num_queue_pairs > I40E_MAX_VSI_QP ||
+               msglen < I40E_VIRTCHNL_CONFIG_VSI_QUEUES_SIZE(vc_vqci,
+                                       vc_vqci->num_queue_pairs)) {
+               PMD_DRV_LOG(ERR, "vsi_queue_config_info argument wrong\n");
                ret = I40E_ERR_PARAM;
                goto send_msg;
        }
@@ -433,17 +438,23 @@ i40e_pf_host_process_cmd_config_vsi_queues(struct i40e_pf_vf *vf,
                        goto send_msg;
                }
 
-               /* Apply VF RX queue setting to HMC */
-               if (i40e_pf_host_hmc_config_rxq(hw, vf, &vc_qpi[i].rxq)
-                       != I40E_SUCCESS) {
+               /*
+                * Apply VF RX queue setting to HMC.
+                * If the opcode is I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EXT,
+                * then the extra information of
+                * 'struct i40e_virtchnl_queue_pair_extra_info' is needed,
+                * otherwise set the last parameter to NULL.
+                */
+               if (i40e_pf_host_hmc_config_rxq(hw, vf, &vc_qpi[i].rxq,
+                       I40E_CFG_CRCSTRIP_DEFAULT) != I40E_SUCCESS) {
                        PMD_DRV_LOG(ERR, "Configure RX queue HMC failed");
                        ret = I40E_ERR_PARAM;
                        goto send_msg;
                }
 
                /* Apply VF TX queue setting to HMC */
-               if (i40e_pf_host_hmc_config_txq(hw, vf, &vc_qpi[i].txq)
-                       != I40E_SUCCESS) {
+               if (i40e_pf_host_hmc_config_txq(hw, vf,
+                       &vc_qpi[i].txq) != I40E_SUCCESS) {
                        PMD_DRV_LOG(ERR, "Configure TX queue HMC failed");
                        ret = I40E_ERR_PARAM;
                        goto send_msg;
@@ -457,6 +468,64 @@ send_msg:
        return ret;
 }
 
+static int
+i40e_pf_host_process_cmd_config_vsi_queues_ext(struct i40e_pf_vf *vf,
+                                              uint8_t *msg,
+                                              uint16_t msglen)
+{
+       struct i40e_hw *hw = I40E_PF_TO_HW(vf->pf);
+       struct i40e_vsi *vsi = vf->vsi;
+       struct i40e_virtchnl_vsi_queue_config_ext_info *vc_vqcei =
+               (struct i40e_virtchnl_vsi_queue_config_ext_info *)msg;
+       struct i40e_virtchnl_queue_pair_ext_info *vc_qpei;
+       int i, ret = I40E_SUCCESS;
+
+       if (!msg || vc_vqcei->num_queue_pairs > vsi->nb_qps ||
+               vc_vqcei->num_queue_pairs > I40E_MAX_VSI_QP ||
+               msglen < I40E_VIRTCHNL_CONFIG_VSI_QUEUES_SIZE(vc_vqcei,
+                                       vc_vqcei->num_queue_pairs)) {
+               PMD_DRV_LOG(ERR, "vsi_queue_config_ext_info argument wrong\n");
+               ret = I40E_ERR_PARAM;
+               goto send_msg;
+       }
+
+       vc_qpei = vc_vqcei->qpair;
+       for (i = 0; i < vc_vqcei->num_queue_pairs; i++) {
+               if (vc_qpei[i].rxq.queue_id > vsi->nb_qps - 1 ||
+                       vc_qpei[i].txq.queue_id > vsi->nb_qps - 1) {
+                       ret = I40E_ERR_PARAM;
+                       goto send_msg;
+               }
+               /*
+                * Apply VF RX queue setting to HMC.
+                * If the opcode is I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EXT,
+                * then the extra information of
+                * 'struct i40e_virtchnl_queue_pair_ext_info' is needed,
+                * otherwise set the last parameter to NULL.
+                */
+               if (i40e_pf_host_hmc_config_rxq(hw, vf, &vc_qpei[i].rxq,
+                       vc_qpei[i].rxq_ext.crcstrip) != I40E_SUCCESS) {
+                       PMD_DRV_LOG(ERR, "Configure RX queue HMC failed");
+                       ret = I40E_ERR_PARAM;
+                       goto send_msg;
+               }
+
+               /* Apply VF TX queue setting to HMC */
+               if (i40e_pf_host_hmc_config_txq(hw, vf, &vc_qpei[i].txq) !=
+                                                       I40E_SUCCESS) {
+                       PMD_DRV_LOG(ERR, "Configure TX queue HMC failed");
+                       ret = I40E_ERR_PARAM;
+                       goto send_msg;
+               }
+       }
+
+send_msg:
+       i40e_pf_host_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EXT,
+                                                               ret, NULL, 0);
+
+       return ret;
+}
+
 static int
 i40e_pf_host_process_cmd_config_irq_map(struct i40e_pf_vf *vf,
                                        uint8_t *msg, uint16_t msglen)
@@ -875,6 +944,11 @@ i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
                PMD_DRV_LOG(INFO, "OP_CONFIG_VSI_QUEUES received");
                i40e_pf_host_process_cmd_config_vsi_queues(vf, msg, msglen);
                break;
+       case I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EXT:
+               PMD_DRV_LOG(INFO, "OP_CONFIG_VSI_QUEUES_EXT received");
+               i40e_pf_host_process_cmd_config_vsi_queues_ext(vf, msg,
+                                                               msglen);
+               break;
        case I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP:
                PMD_DRV_LOG(INFO, "OP_CONFIG_IRQ_MAP received");
                i40e_pf_host_process_cmd_config_irq_map(vf, msg, msglen);