ixgbe/base: calculate X550 checksum
[dpdk.git] / lib / librte_pmd_enic / enic_ethdev.c
index f582152..69ad01b 100644 (file)
 #include "vnic_enet.h"
 #include "enic.h"
 
+#ifdef RTE_LIBRTE_ENIC_DEBUG
 #define ENICPMD_FUNC_TRACE() \
        RTE_LOG(DEBUG, PMD, "ENICPMD trace: %s\n", __func__)
+#else
+#define ENICPMD_FUNC_TRACE() (void)0
+#endif
 
 /*
  * The set of PCI devices this driver supports
  */
-static struct rte_pci_id pci_id_enic_map[] = {
+static const struct rte_pci_id pci_id_enic_map[] = {
 #define RTE_PCI_DEV_ID_DECL_ENIC(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
 #ifndef PCI_VENDOR_ID_CISCO
 #define PCI_VENDOR_ID_CISCO    0x1137
@@ -65,33 +69,64 @@ RTE_PCI_DEV_ID_DECL_ENIC(PCI_VENDOR_ID_CISCO, PCI_DEVICE_ID_CISCO_VIC_ENET_VF)
 {.vendor_id = 0, /* Sentinal */},
 };
 
-static int enicpmd_fdir_remove_perfect_filter(struct rte_eth_dev *eth_dev,
-               struct rte_fdir_filter *fdir_filter,
-               uint16_t soft_id)
+static int
+enicpmd_fdir_ctrl_func(struct rte_eth_dev *eth_dev,
+                       enum rte_filter_op filter_op, void *arg)
 {
        struct enic *enic = pmd_priv(eth_dev);
+       int ret = 0;
 
        ENICPMD_FUNC_TRACE();
-       return enic_fdir_del_fltr(enic, fdir_filter);
-}
-
-static int enicpmd_fdir_add_perfect_filter(struct rte_eth_dev *eth_dev,
-       struct rte_fdir_filter *fdir_filter, uint16_t soft_id,
-       uint8_t queue, uint8_t drop)
-{
-       struct enic *enic = pmd_priv(eth_dev);
+       if (filter_op == RTE_ETH_FILTER_NOP)
+               return 0;
 
-       ENICPMD_FUNC_TRACE();
-       return enic_fdir_add_fltr(enic, fdir_filter, (uint16_t)queue, drop);
+       if (arg == NULL && filter_op != RTE_ETH_FILTER_FLUSH)
+               return -EINVAL;
+
+       switch (filter_op) {
+       case RTE_ETH_FILTER_ADD:
+       case RTE_ETH_FILTER_UPDATE:
+               ret = enic_fdir_add_fltr(enic,
+                       (struct rte_eth_fdir_filter *)arg);
+               break;
+
+       case RTE_ETH_FILTER_DELETE:
+               ret = enic_fdir_del_fltr(enic,
+                       (struct rte_eth_fdir_filter *)arg);
+               break;
+
+       case RTE_ETH_FILTER_STATS:
+               enic_fdir_stats_get(enic, (struct rte_eth_fdir_stats *)arg);
+               break;
+
+       case RTE_ETH_FILTER_FLUSH:
+       case RTE_ETH_FILTER_INFO:
+               dev_warning(enic, "unsupported operation %u", filter_op);
+               ret = -ENOTSUP;
+               break;
+       default:
+               dev_err(enic, "unknown operation %u", filter_op);
+               ret = -EINVAL;
+               break;
+       }
+       return ret;
 }
 
-static void enicpmd_fdir_info_get(struct rte_eth_dev *eth_dev,
-       struct rte_eth_fdir *fdir)
+static int
+enicpmd_dev_filter_ctrl(struct rte_eth_dev *dev,
+                    enum rte_filter_type filter_type,
+                    enum rte_filter_op filter_op,
+                    void *arg)
 {
-       struct enic *enic = pmd_priv(eth_dev);
+       int ret = -EINVAL;
 
-       ENICPMD_FUNC_TRACE();
-       *fdir = enic->fdir.stats;
+       if (RTE_ETH_FILTER_FDIR == filter_type)
+               ret = enicpmd_fdir_ctrl_func(dev, filter_op, arg);
+       else
+               dev_warning(enic, "Filter type (%d) not supported",
+                       filter_type);
+
+       return ret;
 }
 
 static void enicpmd_dev_tx_queue_release(void *txq)
@@ -103,7 +138,7 @@ static void enicpmd_dev_tx_queue_release(void *txq)
 static int enicpmd_dev_setup_intr(struct enic *enic)
 {
        int ret;
-       int index;
+       unsigned int index;
 
        ENICPMD_FUNC_TRACE();
 
@@ -134,7 +169,7 @@ static int enicpmd_dev_tx_queue_setup(struct rte_eth_dev *eth_dev,
        uint16_t queue_idx,
        uint16_t nb_desc,
        unsigned int socket_id,
-       const struct rte_eth_txconf *tx_conf)
+       __rte_unused const struct rte_eth_txconf *tx_conf)
 {
        int ret;
        struct enic *enic = pmd_priv(eth_dev);
@@ -215,7 +250,7 @@ static int enicpmd_dev_rx_queue_setup(struct rte_eth_dev *eth_dev,
        uint16_t queue_idx,
        uint16_t nb_desc,
        unsigned int socket_id,
-       const struct rte_eth_rxconf *rx_conf,
+       __rte_unused const struct rte_eth_rxconf *rx_conf,
        struct rte_mempool *mp)
 {
        int ret;
@@ -334,7 +369,7 @@ static void enicpmd_dev_close(struct rte_eth_dev *eth_dev)
 }
 
 static int enicpmd_dev_link_update(struct rte_eth_dev *eth_dev,
-       int wait_to_complete)
+       __rte_unused int wait_to_complete)
 {
        struct enic *enic = pmd_priv(eth_dev);
        int ret;
@@ -428,7 +463,7 @@ static void enicpmd_dev_allmulticast_disable(struct rte_eth_dev *eth_dev)
 
 static void enicpmd_add_mac_addr(struct rte_eth_dev *eth_dev,
        struct ether_addr *mac_addr,
-       uint32_t index, uint32_t pool)
+       __rte_unused uint32_t index, __rte_unused uint32_t pool)
 {
        struct enic *enic = pmd_priv(eth_dev);
 
@@ -436,7 +471,7 @@ static void enicpmd_add_mac_addr(struct rte_eth_dev *eth_dev,
        enic_set_mac_address(enic, mac_addr->addr_bytes);
 }
 
-static void enicpmd_remove_mac_addr(struct rte_eth_dev *eth_dev, uint32_t index)
+static void enicpmd_remove_mac_addr(struct rte_eth_dev *eth_dev, __rte_unused uint32_t index)
 {
        struct enic *enic = pmd_priv(eth_dev);
 
@@ -457,7 +492,6 @@ static uint16_t enicpmd_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
        struct rte_mbuf *tx_pkt;
        struct vnic_wq *wq = (struct vnic_wq *)tx_queue;
        struct enic *enic = vnic_dev_priv(wq->vdev);
-       unsigned char *buf;
        unsigned short vlan_id;
        unsigned short ol_flags;
 
@@ -504,7 +538,7 @@ static uint16_t enicpmd_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
        return work_done;
 }
 
-static struct eth_dev_ops enicpmd_eth_dev_ops = {
+static const struct eth_dev_ops enicpmd_eth_dev_ops = {
        .dev_configure        = enicpmd_dev_configure,
        .dev_start            = enicpmd_dev_start,
        .dev_stop             = enicpmd_dev_stop,
@@ -542,23 +576,15 @@ static struct eth_dev_ops enicpmd_eth_dev_ops = {
        .priority_flow_ctrl_set = NULL,
        .mac_addr_add         = enicpmd_add_mac_addr,
        .mac_addr_remove      = enicpmd_remove_mac_addr,
-       .fdir_add_signature_filter    = NULL,
-       .fdir_update_signature_filter = NULL,
-       .fdir_remove_signature_filter = NULL,
-       .fdir_infos_get               = enicpmd_fdir_info_get,
-       .fdir_add_perfect_filter      = enicpmd_fdir_add_perfect_filter,
-       .fdir_update_perfect_filter   = enicpmd_fdir_add_perfect_filter,
-       .fdir_remove_perfect_filter   = enicpmd_fdir_remove_perfect_filter,
        .fdir_set_masks               = NULL,
+       .filter_ctrl          = enicpmd_dev_filter_ctrl,
 };
 
 struct enic *enicpmd_list_head = NULL;
 /* Initialize the driver
  * It returns 0 on success.
  */
-static int eth_enicpmd_dev_init(
-       __attribute__((unused))struct eth_driver *eth_drv,
-       struct rte_eth_dev *eth_dev)
+static int eth_enicpmd_dev_init(struct rte_eth_dev *eth_dev)
 {
        struct rte_pci_device *pdev;
        struct rte_pci_addr *addr;
@@ -566,6 +592,7 @@ static int eth_enicpmd_dev_init(
 
        ENICPMD_FUNC_TRACE();
 
+       enic->port_id = eth_dev->data->port_id;
        enic->rte_dev = eth_dev;
        eth_dev->dev_ops = &enicpmd_eth_dev_ops;
        eth_dev->rx_pkt_burst = &enicpmd_recv_pkts;
@@ -595,7 +622,8 @@ static struct eth_driver rte_enic_pmd = {
  * Invoked once at EAL init time.
  * Register as the [Poll Mode] Driver of Cisco ENIC device.
  */
-int rte_enic_pmd_init(const char *name __rte_unused,
+static int
+rte_enic_pmd_init(const char *name __rte_unused,
        const char *params __rte_unused)
 {
        ENICPMD_FUNC_TRACE();