net/ice: support advance Rx/Tx
[dpdk.git] / drivers / net / ice / ice_ethdev.c
index 7c9ddcb..c0c530f 100644 (file)
@@ -52,8 +52,13 @@ static int ice_rx_queue_intr_enable(struct rte_eth_dev *dev,
                                    uint16_t queue_id);
 static int ice_rx_queue_intr_disable(struct rte_eth_dev *dev,
                                     uint16_t queue_id);
+static int ice_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+                             size_t fw_size);
 static int ice_vlan_pvid_set(struct rte_eth_dev *dev,
                             uint16_t pvid, int on);
+static int ice_get_eeprom_length(struct rte_eth_dev *dev);
+static int ice_get_eeprom(struct rte_eth_dev *dev,
+                         struct rte_dev_eeprom_info *eeprom);
 
 static const struct rte_pci_id pci_id_ice_map[] = {
        { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E810C_BACKPLANE) },
@@ -92,9 +97,12 @@ static const struct eth_dev_ops ice_eth_dev_ops = {
        .rss_hash_conf_get            = ice_rss_hash_conf_get,
        .rx_queue_intr_enable         = ice_rx_queue_intr_enable,
        .rx_queue_intr_disable        = ice_rx_queue_intr_disable,
+       .fw_version_get               = ice_fw_version_get,
        .vlan_pvid_set                = ice_vlan_pvid_set,
        .rxq_info_get                 = ice_rxq_info_get,
        .txq_info_get                 = ice_txq_info_get,
+       .get_eeprom_length            = ice_get_eeprom_length,
+       .get_eeprom                   = ice_get_eeprom,
        .rx_queue_count               = ice_rx_queue_count,
 };
 
@@ -1718,6 +1726,7 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
                DEV_RX_OFFLOAD_VLAN_EXTEND |
                DEV_RX_OFFLOAD_JUMBO_FRAME |
                DEV_RX_OFFLOAD_KEEP_CRC |
+               DEV_RX_OFFLOAD_SCATTER |
                DEV_RX_OFFLOAD_VLAN_FILTER;
        dev_info->tx_offload_capa =
                DEV_TX_OFFLOAD_VLAN_INSERT |
@@ -1728,7 +1737,8 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
                DEV_TX_OFFLOAD_SCTP_CKSUM |
                DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM |
                DEV_TX_OFFLOAD_TCP_TSO |
-               DEV_TX_OFFLOAD_MULTI_SEGS;
+               DEV_TX_OFFLOAD_MULTI_SEGS |
+               DEV_TX_OFFLOAD_MBUF_FAST_FREE;
        dev_info->rx_queue_offload_capa = 0;
        dev_info->tx_queue_offload_capa = 0;
 
@@ -2482,6 +2492,24 @@ static int ice_rx_queue_intr_disable(struct rte_eth_dev *dev,
        return 0;
 }
 
+static int
+ice_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
+{
+       struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+       int ret;
+
+       ret = snprintf(fw_version, fw_size, "%d.%d.%05d %d.%d",
+                      hw->fw_maj_ver, hw->fw_min_ver, hw->fw_build,
+                      hw->api_maj_ver, hw->api_min_ver);
+
+       /* add the size of '\0' */
+       ret += 1;
+       if (fw_size < (u32)ret)
+               return ret;
+       else
+               return 0;
+}
+
 static int
 ice_vsi_vlan_pvid_set(struct ice_vsi *vsi, struct ice_vsi_vlan_pvid_info *info)
 {
@@ -2564,6 +2592,46 @@ ice_vlan_pvid_set(struct rte_eth_dev *dev, uint16_t pvid, int on)
        return 0;
 }
 
+static int
+ice_get_eeprom_length(struct rte_eth_dev *dev)
+{
+       struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+       /* Convert word count to byte count */
+       return hw->nvm.sr_words << 1;
+}
+
+static int
+ice_get_eeprom(struct rte_eth_dev *dev,
+              struct rte_dev_eeprom_info *eeprom)
+{
+       struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+       uint16_t *data = eeprom->data;
+       uint16_t offset, length, i;
+       enum ice_status ret_code = ICE_SUCCESS;
+
+       offset = eeprom->offset >> 1;
+       length = eeprom->length >> 1;
+
+       if (offset > hw->nvm.sr_words ||
+           offset + length > hw->nvm.sr_words) {
+               PMD_DRV_LOG(ERR, "Requested EEPROM bytes out of range.");
+               return -EINVAL;
+       }
+
+       eeprom->magic = hw->vendor_id | (hw->device_id << 16);
+
+       for (i = 0; i < length; i++) {
+               ret_code = ice_read_sr_word(hw, offset + i, &data[i]);
+               if (ret_code != ICE_SUCCESS) {
+                       PMD_DRV_LOG(ERR, "EEPROM read failed.");
+                       return -EIO;
+               }
+       }
+
+       return 0;
+}
+
 static int
 ice_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
              struct rte_pci_device *pci_dev)