net/bnx2x: convert to new Rx offloads API
[dpdk.git] / drivers / net / axgbe / axgbe_ethdev.c
index defe54b..a9a9fb5 100644 (file)
@@ -15,8 +15,15 @@ static int  axgbe_dev_start(struct rte_eth_dev *dev);
 static void axgbe_dev_stop(struct rte_eth_dev *dev);
 static void axgbe_dev_interrupt_handler(void *param);
 static void axgbe_dev_close(struct rte_eth_dev *dev);
+static void axgbe_dev_promiscuous_enable(struct rte_eth_dev *dev);
+static void axgbe_dev_promiscuous_disable(struct rte_eth_dev *dev);
+static void axgbe_dev_allmulticast_enable(struct rte_eth_dev *dev);
+static void axgbe_dev_allmulticast_disable(struct rte_eth_dev *dev);
 static int axgbe_dev_link_update(struct rte_eth_dev *dev,
                                 int wait_to_complete);
+static int axgbe_dev_stats_get(struct rte_eth_dev *dev,
+                               struct rte_eth_stats *stats);
+static void axgbe_dev_stats_reset(struct rte_eth_dev *dev);
 static void axgbe_dev_info_get(struct rte_eth_dev *dev,
                               struct rte_eth_dev_info *dev_info);
 
@@ -43,6 +50,7 @@ static struct axgbe_version_data axgbe_v2a = {
        .tx_tstamp_workaround           = 1,
        .ecc_support                    = 1,
        .i2c_support                    = 1,
+       .an_cdr_workaround              = 1,
 };
 
 static struct axgbe_version_data axgbe_v2b = {
@@ -54,6 +62,7 @@ static struct axgbe_version_data axgbe_v2b = {
        .tx_tstamp_workaround           = 1,
        .ecc_support                    = 1,
        .i2c_support                    = 1,
+       .an_cdr_workaround              = 1,
 };
 
 static const struct rte_eth_desc_lim rx_desc_lim = {
@@ -73,7 +82,13 @@ static const struct eth_dev_ops axgbe_eth_dev_ops = {
        .dev_start            = axgbe_dev_start,
        .dev_stop             = axgbe_dev_stop,
        .dev_close            = axgbe_dev_close,
+       .promiscuous_enable   = axgbe_dev_promiscuous_enable,
+       .promiscuous_disable  = axgbe_dev_promiscuous_disable,
+       .allmulticast_enable  = axgbe_dev_allmulticast_enable,
+       .allmulticast_disable = axgbe_dev_allmulticast_disable,
        .link_update          = axgbe_dev_link_update,
+       .stats_get            = axgbe_dev_stats_get,
+       .stats_reset          = axgbe_dev_stats_reset,
        .dev_infos_get        = axgbe_dev_info_get,
        .rx_queue_setup       = axgbe_dev_rx_queue_setup,
        .rx_queue_release     = axgbe_dev_rx_queue_release,
@@ -219,6 +234,46 @@ axgbe_dev_close(struct rte_eth_dev *dev)
        axgbe_dev_clear_queues(dev);
 }
 
+static void
+axgbe_dev_promiscuous_enable(struct rte_eth_dev *dev)
+{
+       PMD_INIT_FUNC_TRACE();
+       struct axgbe_port *pdata = dev->data->dev_private;
+
+       AXGMAC_IOWRITE_BITS(pdata, MAC_PFR, PR, 1);
+}
+
+static void
+axgbe_dev_promiscuous_disable(struct rte_eth_dev *dev)
+{
+       PMD_INIT_FUNC_TRACE();
+       struct axgbe_port *pdata = dev->data->dev_private;
+
+       AXGMAC_IOWRITE_BITS(pdata, MAC_PFR, PR, 0);
+}
+
+static void
+axgbe_dev_allmulticast_enable(struct rte_eth_dev *dev)
+{
+       PMD_INIT_FUNC_TRACE();
+       struct axgbe_port *pdata = dev->data->dev_private;
+
+       if (AXGMAC_IOREAD_BITS(pdata, MAC_PFR, PM))
+               return;
+       AXGMAC_IOWRITE_BITS(pdata, MAC_PFR, PM, 1);
+}
+
+static void
+axgbe_dev_allmulticast_disable(struct rte_eth_dev *dev)
+{
+       PMD_INIT_FUNC_TRACE();
+       struct axgbe_port *pdata = dev->data->dev_private;
+
+       if (!AXGMAC_IOREAD_BITS(pdata, MAC_PFR, PM))
+               return;
+       AXGMAC_IOWRITE_BITS(pdata, MAC_PFR, PM, 0);
+}
+
 /* return 0 means link status changed, -1 means not changed */
 static int
 axgbe_dev_link_update(struct rte_eth_dev *dev,
@@ -246,6 +301,53 @@ axgbe_dev_link_update(struct rte_eth_dev *dev,
        return ret;
 }
 
+static int
+axgbe_dev_stats_get(struct rte_eth_dev *dev,
+                   struct rte_eth_stats *stats)
+{
+       struct axgbe_rx_queue *rxq;
+       struct axgbe_tx_queue *txq;
+       unsigned int i;
+
+       for (i = 0; i < dev->data->nb_rx_queues; i++) {
+               rxq = dev->data->rx_queues[i];
+               stats->q_ipackets[i] = rxq->pkts;
+               stats->ipackets += rxq->pkts;
+               stats->q_ibytes[i] = rxq->bytes;
+               stats->ibytes += rxq->bytes;
+       }
+       for (i = 0; i < dev->data->nb_tx_queues; i++) {
+               txq = dev->data->tx_queues[i];
+               stats->q_opackets[i] = txq->pkts;
+               stats->opackets += txq->pkts;
+               stats->q_obytes[i] = txq->bytes;
+               stats->obytes += txq->bytes;
+       }
+
+       return 0;
+}
+
+static void
+axgbe_dev_stats_reset(struct rte_eth_dev *dev)
+{
+       struct axgbe_rx_queue *rxq;
+       struct axgbe_tx_queue *txq;
+       unsigned int i;
+
+       for (i = 0; i < dev->data->nb_rx_queues; i++) {
+               rxq = dev->data->rx_queues[i];
+               rxq->pkts = 0;
+               rxq->bytes = 0;
+               rxq->errors = 0;
+       }
+       for (i = 0; i < dev->data->nb_tx_queues; i++) {
+               txq = dev->data->tx_queues[i];
+               txq->pkts = 0;
+               txq->bytes = 0;
+               txq->errors = 0;
+       }
+}
+
 static void
 axgbe_dev_info_get(struct rte_eth_dev *dev,
                   struct rte_eth_dev_info *dev_info)
@@ -489,10 +591,12 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
        pdata->pci_dev = pci_dev;
 
        pdata->xgmac_regs =
-               (uint64_t)pci_dev->mem_resource[AXGBE_AXGMAC_BAR].addr;
-       pdata->xprop_regs = pdata->xgmac_regs + AXGBE_MAC_PROP_OFFSET;
-       pdata->xi2c_regs = pdata->xgmac_regs + AXGBE_I2C_CTRL_OFFSET;
-       pdata->xpcs_regs = (uint64_t)pci_dev->mem_resource[AXGBE_XPCS_BAR].addr;
+               (void *)pci_dev->mem_resource[AXGBE_AXGMAC_BAR].addr;
+       pdata->xprop_regs = (void *)((uint8_t *)pdata->xgmac_regs
+                                    + AXGBE_MAC_PROP_OFFSET);
+       pdata->xi2c_regs = (void *)((uint8_t *)pdata->xgmac_regs
+                                   + AXGBE_I2C_CTRL_OFFSET);
+       pdata->xpcs_regs = (void *)pci_dev->mem_resource[AXGBE_XPCS_BAR].addr;
 
        /* version specific driver data*/
        if (pci_dev->id.device_id == AMD_PCI_AXGBE_DEVICE_V2A)