fix typos using codespell utility
[dpdk.git] / drivers / net / enic / enic_main.c
index bf9b051..2192c7f 100644 (file)
@@ -137,6 +137,7 @@ static void enic_clear_soft_stats(struct enic *enic)
        struct enic_soft_stats *soft_stats = &enic->soft_stats;
        rte_atomic64_clear(&soft_stats->rx_nombuf);
        rte_atomic64_clear(&soft_stats->rx_packet_errors);
+       rte_atomic64_clear(&soft_stats->tx_oversized);
 }
 
 static void enic_init_soft_stats(struct enic *enic)
@@ -144,6 +145,7 @@ static void enic_init_soft_stats(struct enic *enic)
        struct enic_soft_stats *soft_stats = &enic->soft_stats;
        rte_atomic64_init(&soft_stats->rx_nombuf);
        rte_atomic64_init(&soft_stats->rx_packet_errors);
+       rte_atomic64_init(&soft_stats->tx_oversized);
        enic_clear_soft_stats(enic);
 }
 
@@ -183,42 +185,36 @@ void enic_dev_stats_get(struct enic *enic, struct rte_eth_stats *r_stats)
        r_stats->obytes = stats->tx.tx_bytes_ok;
 
        r_stats->ierrors = stats->rx.rx_errors + stats->rx.rx_drop;
-       r_stats->oerrors = stats->tx.tx_errors;
+       r_stats->oerrors = stats->tx.tx_errors
+                          + rte_atomic64_read(&soft_stats->tx_oversized);
 
        r_stats->imissed = stats->rx.rx_no_bufs + rx_truncated;
 
        r_stats->rx_nombuf = rte_atomic64_read(&soft_stats->rx_nombuf);
 }
 
-void enic_del_mac_address(struct enic *enic)
+void enic_del_mac_address(struct enic *enic, int mac_index)
 {
-       if (vnic_dev_del_addr(enic->vdev, enic->mac_addr))
+       struct rte_eth_dev *eth_dev = enic->rte_dev;
+       uint8_t *mac_addr = eth_dev->data->mac_addrs[mac_index].addr_bytes;
+
+       if (vnic_dev_del_addr(enic->vdev, mac_addr))
                dev_err(enic, "del mac addr failed\n");
 }
 
-void enic_set_mac_address(struct enic *enic, uint8_t *mac_addr)
+int enic_set_mac_address(struct enic *enic, uint8_t *mac_addr)
 {
        int err;
 
        if (!is_eth_addr_valid(mac_addr)) {
                dev_err(enic, "invalid mac address\n");
-               return;
-       }
-
-       err = vnic_dev_del_addr(enic->vdev, enic->mac_addr);
-       if (err) {
-               dev_err(enic, "del mac addr failed\n");
-               return;
+               return -EINVAL;
        }
 
-       ether_addr_copy((struct ether_addr *)mac_addr,
-               (struct ether_addr *)enic->mac_addr);
-
        err = vnic_dev_add_addr(enic->vdev, mac_addr);
-       if (err) {
+       if (err)
                dev_err(enic, "add mac addr failed\n");
-               return;
-       }
+       return err;
 }
 
 static void
@@ -426,8 +422,7 @@ int enic_link_update(struct enic *enic)
 }
 
 static void
-enic_intr_handler(__rte_unused struct rte_intr_handle *handle,
-       void *arg)
+enic_intr_handler(void *arg)
 {
        struct rte_eth_dev *dev = (struct rte_eth_dev *)arg;
        struct enic *enic = pmd_priv(dev);
@@ -606,7 +601,7 @@ int enic_stop_rq(struct enic *enic, uint16_t queue_idx)
 
 int enic_alloc_rq(struct enic *enic, uint16_t queue_idx,
        unsigned int socket_id, struct rte_mempool *mp,
-       uint16_t nb_desc)
+       uint16_t nb_desc, uint16_t free_thresh)
 {
        int rc;
        uint16_t sop_queue_idx = enic_rte_rq_idx_to_sop_idx(queue_idx);
@@ -627,6 +622,10 @@ int enic_alloc_rq(struct enic *enic, uint16_t queue_idx,
        rq_data->socket_id = socket_id;
        rq_data->mp = mp;
        rq_sop->in_use = 1;
+       rq_sop->rx_free_thresh = free_thresh;
+       rq_data->rx_free_thresh = free_thresh;
+       dev_debug(enic, "Set queue_id:%u free thresh:%u\n", queue_idx,
+                 free_thresh);
 
        mbuf_size = (uint16_t)(rte_pktmbuf_data_room_size(mp) -
                               RTE_PKTMBUF_HEADROOM);
@@ -1226,7 +1225,7 @@ int enic_set_mtu(struct enic *enic, uint16_t new_mtu)
                }
        }
 
-       /* replace Rx funciton with a no-op to avoid getting stale pkts */
+       /* replace Rx function with a no-op to avoid getting stale pkts */
        eth_dev->rx_pkt_burst = enic_dummy_recv_pkts;
        rte_mb();
 
@@ -1244,7 +1243,7 @@ int enic_set_mtu(struct enic *enic, uint16_t new_mtu)
 
                enic_free_rq(rq);
                rc = enic_alloc_rq(enic, rq_idx, rq->socket_id, rq->mp,
-                                  rq->tot_nb_desc);
+                                  rq->tot_nb_desc, rq->rx_free_thresh);
                if (rc) {
                        dev_err(enic,
                                "Fatal MTU alloc error- No traffic will pass\n");
@@ -1304,16 +1303,20 @@ static int enic_dev_init(struct enic *enic)
        /* Get the supported filters */
        enic_fdir_info(enic);
 
-       eth_dev->data->mac_addrs = rte_zmalloc("enic_mac_addr", ETH_ALEN, 0);
+       eth_dev->data->mac_addrs = rte_zmalloc("enic_mac_addr", ETH_ALEN
+                                               * ENIC_MAX_MAC_ADDR, 0);
        if (!eth_dev->data->mac_addrs) {
                dev_err(enic, "mac addr storage alloc failed, aborting.\n");
                return -1;
        }
        ether_addr_copy((struct ether_addr *) enic->mac_addr,
-               &eth_dev->data->mac_addrs[0]);
+                       eth_dev->data->mac_addrs);
 
        vnic_dev_set_reset_flag(enic->vdev, 0);
 
+       LIST_INIT(&enic->flows);
+       rte_spinlock_init(&enic->flows_lock);
+
        /* set up link status checking */
        vnic_dev_notify_set(enic->vdev, -1); /* No Intr for notify */