static int
alloc_rxq_mbufs(struct ice_rx_queue *rxq)
{
- volatile union ice_32b_rx_flex_desc *rxd;
+ volatile union ice_rx_flex_desc *rxd;
struct rte_mbuf *mbuf = NULL;
uint64_t dma_addr;
uint16_t i;
rxd = &rxq->rx_ring[i];
rxd->read.pkt_addr = dma_addr;
rxd->read.hdr_addr = 0;
+#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
rxd->read.rsvd1 = 0;
rxd->read.rsvd2 = 0;
+#endif
rxq->sw_ring[i].mbuf = (void *)mbuf;
}
return ret;
}
+ ret = ice_dcf_add_del_all_mac_addr(hw, true);
+ if (ret) {
+ PMD_DRV_LOG(ERR, "Failed to add mac addr");
+ return ret;
+ }
+
dev->data->dev_link.link_status = ETH_LINK_UP;
return 0;
}
}
-static void
+static int
ice_dcf_dev_stop(struct rte_eth_dev *dev)
{
struct ice_dcf_adapter *dcf_ad = dev->data->dev_private;
if (ad->pf.adapter_stopped == 1) {
PMD_DRV_LOG(DEBUG, "Port is already stopped");
- return;
+ return 0;
}
ice_dcf_stop_queues(dev);
intr_handle->intr_vec = NULL;
}
+ ice_dcf_add_del_all_mac_addr(&dcf_ad->real_hw, false);
dev->data->dev_link.link_status = ETH_LINK_DOWN;
ad->pf.adapter_stopped = 1;
+
+ return 0;
}
static int
return 0;
}
-static int
-ice_dcf_stats_get(__rte_unused struct rte_eth_dev *dev,
- __rte_unused struct rte_eth_stats *igb_stats)
-{
- return 0;
-}
-
-static int
-ice_dcf_stats_reset(__rte_unused struct rte_eth_dev *dev)
-{
- return 0;
-}
-
static int
ice_dcf_dev_promiscuous_enable(__rte_unused struct rte_eth_dev *dev)
{
return ret;
}
+#define ICE_DCF_32_BIT_WIDTH (CHAR_BIT * 4)
+#define ICE_DCF_48_BIT_WIDTH (CHAR_BIT * 6)
+#define ICE_DCF_48_BIT_MASK RTE_LEN2MASK(ICE_DCF_48_BIT_WIDTH, uint64_t)
+
+static void
+ice_dcf_stat_update_48(uint64_t *offset, uint64_t *stat)
+{
+ if (*stat >= *offset)
+ *stat = *stat - *offset;
+ else
+ *stat = (uint64_t)((*stat +
+ ((uint64_t)1 << ICE_DCF_48_BIT_WIDTH)) - *offset);
+
+ *stat &= ICE_DCF_48_BIT_MASK;
+}
+
+static void
+ice_dcf_stat_update_32(uint64_t *offset, uint64_t *stat)
+{
+ if (*stat >= *offset)
+ *stat = (uint64_t)(*stat - *offset);
+ else
+ *stat = (uint64_t)((*stat +
+ ((uint64_t)1 << ICE_DCF_32_BIT_WIDTH)) - *offset);
+}
+
static void
+ice_dcf_update_stats(struct virtchnl_eth_stats *oes,
+ struct virtchnl_eth_stats *nes)
+{
+ ice_dcf_stat_update_48(&oes->rx_bytes, &nes->rx_bytes);
+ ice_dcf_stat_update_48(&oes->rx_unicast, &nes->rx_unicast);
+ ice_dcf_stat_update_48(&oes->rx_multicast, &nes->rx_multicast);
+ ice_dcf_stat_update_48(&oes->rx_broadcast, &nes->rx_broadcast);
+ ice_dcf_stat_update_32(&oes->rx_discards, &nes->rx_discards);
+ ice_dcf_stat_update_48(&oes->tx_bytes, &nes->tx_bytes);
+ ice_dcf_stat_update_48(&oes->tx_unicast, &nes->tx_unicast);
+ ice_dcf_stat_update_48(&oes->tx_multicast, &nes->tx_multicast);
+ ice_dcf_stat_update_48(&oes->tx_broadcast, &nes->tx_broadcast);
+ ice_dcf_stat_update_32(&oes->tx_errors, &nes->tx_errors);
+ ice_dcf_stat_update_32(&oes->tx_discards, &nes->tx_discards);
+}
+
+
+static int
+ice_dcf_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+{
+ struct ice_dcf_adapter *ad = dev->data->dev_private;
+ struct ice_dcf_hw *hw = &ad->real_hw;
+ struct virtchnl_eth_stats pstats;
+ int ret;
+
+ ret = ice_dcf_query_stats(hw, &pstats);
+ if (ret == 0) {
+ ice_dcf_update_stats(&hw->eth_stats_offset, &pstats);
+ stats->ipackets = pstats.rx_unicast + pstats.rx_multicast +
+ pstats.rx_broadcast - pstats.rx_discards;
+ stats->opackets = pstats.tx_broadcast + pstats.tx_multicast +
+ pstats.tx_unicast;
+ stats->imissed = pstats.rx_discards;
+ stats->oerrors = pstats.tx_errors + pstats.tx_discards;
+ stats->ibytes = pstats.rx_bytes;
+ stats->ibytes -= stats->ipackets * RTE_ETHER_CRC_LEN;
+ stats->obytes = pstats.tx_bytes;
+ } else {
+ PMD_DRV_LOG(ERR, "Get statistics failed");
+ }
+ return ret;
+}
+
+static int
+ice_dcf_stats_reset(struct rte_eth_dev *dev)
+{
+ struct ice_dcf_adapter *ad = dev->data->dev_private;
+ struct ice_dcf_hw *hw = &ad->real_hw;
+ struct virtchnl_eth_stats pstats;
+ int ret;
+
+ /* read stat values to clear hardware registers */
+ ret = ice_dcf_query_stats(hw, &pstats);
+ if (ret != 0)
+ return ret;
+
+ /* set stats offset base on current values */
+ hw->eth_stats_offset = pstats;
+
+ return 0;
+}
+
+static int
ice_dcf_dev_close(struct rte_eth_dev *dev)
{
struct ice_dcf_adapter *adapter = dev->data->dev_private;
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
- return;
-
- dev->dev_ops = NULL;
- dev->rx_pkt_burst = NULL;
- dev->tx_pkt_burst = NULL;
+ return 0;
ice_dcf_uninit_parent_adapter(dev);
ice_dcf_uninit_hw(dev, &adapter->real_hw);
+
+ return 0;
}
static int
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
- eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
+ eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
adapter->real_hw.vc_event_msg_cb = ice_dcf_handle_pf_event_msg;
if (ice_dcf_init_hw(eth_dev, &adapter->real_hw) != 0) {
return ret;
}
-static int eth_ice_dcf_pci_probe(__rte_unused struct rte_pci_driver *pci_drv,
- struct rte_pci_device *pci_dev)
+static int
+eth_ice_dcf_pci_probe(__rte_unused struct rte_pci_driver *pci_drv,
+ struct rte_pci_device *pci_dev)
{
+ struct rte_eth_devargs eth_da = { .nb_representor_ports = 0 };
+ struct ice_dcf_vf_repr_param repr_param;
+ char repr_name[RTE_ETH_NAME_MAX_LEN];
+ struct ice_dcf_adapter *dcf_adapter;
+ struct rte_eth_dev *dcf_ethdev;
+ uint16_t dcf_vsi_id;
+ int i, ret;
+
if (!ice_dcf_cap_selected(pci_dev->device.devargs))
return 1;
- return rte_eth_dev_pci_generic_probe(pci_dev,
- sizeof(struct ice_dcf_adapter),
- ice_dcf_dev_init);
+ ret = rte_eth_devargs_parse(pci_dev->device.devargs->args, ð_da);
+ if (ret)
+ return ret;
+
+ ret = rte_eth_dev_pci_generic_probe(pci_dev,
+ sizeof(struct ice_dcf_adapter),
+ ice_dcf_dev_init);
+ if (ret || !eth_da.nb_representor_ports)
+ return ret;
+
+ dcf_ethdev = rte_eth_dev_allocated(pci_dev->device.name);
+ if (dcf_ethdev == NULL)
+ return -ENODEV;
+
+ dcf_adapter = dcf_ethdev->data->dev_private;
+
+ if (eth_da.nb_representor_ports > dcf_adapter->real_hw.num_vfs ||
+ eth_da.nb_representor_ports >= RTE_MAX_ETHPORTS) {
+ PMD_DRV_LOG(ERR, "the number of port representors is too large: %u",
+ eth_da.nb_representor_ports);
+ return -EINVAL;
+ }
+
+ dcf_vsi_id = dcf_adapter->real_hw.vsi_id | VIRTCHNL_DCF_VF_VSI_VALID;
+
+ repr_param.adapter = dcf_adapter;
+ repr_param.switch_domain_id = 0;
+
+ for (i = 0; i < eth_da.nb_representor_ports; i++) {
+ uint16_t vf_id = eth_da.representor_ports[i];
+
+ if (vf_id >= dcf_adapter->real_hw.num_vfs) {
+ PMD_DRV_LOG(ERR, "VF ID %u is out of range (0 ~ %u)",
+ vf_id, dcf_adapter->real_hw.num_vfs - 1);
+ ret = -EINVAL;
+ break;
+ }
+
+ if (dcf_adapter->real_hw.vf_vsi_map[vf_id] == dcf_vsi_id) {
+ PMD_DRV_LOG(ERR, "VF ID %u is DCF's ID.\n", vf_id);
+ ret = -EINVAL;
+ break;
+ }
+
+ repr_param.vf_id = vf_id;
+ snprintf(repr_name, sizeof(repr_name), "net_%s_representor_%u",
+ pci_dev->device.name, vf_id);
+ ret = rte_eth_dev_create(&pci_dev->device, repr_name,
+ sizeof(struct ice_dcf_vf_repr),
+ NULL, NULL, ice_dcf_vf_repr_init,
+ &repr_param);
+ if (ret) {
+ PMD_DRV_LOG(ERR, "failed to create DCF VF representor %s",
+ repr_name);
+ break;
+ }
+ }
+
+ return ret;
}
-static int eth_ice_dcf_pci_remove(struct rte_pci_device *pci_dev)
+static int
+eth_ice_dcf_pci_remove(struct rte_pci_device *pci_dev)
{
- return rte_eth_dev_pci_generic_remove(pci_dev, ice_dcf_dev_uninit);
+ struct rte_eth_dev *eth_dev;
+
+ eth_dev = rte_eth_dev_allocated(pci_dev->device.name);
+ if (!eth_dev)
+ return 0;
+
+ if (eth_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
+ return rte_eth_dev_pci_generic_remove(pci_dev,
+ ice_dcf_vf_repr_uninit);
+ else
+ return rte_eth_dev_pci_generic_remove(pci_dev,
+ ice_dcf_dev_uninit);
}
static const struct rte_pci_id pci_id_ice_dcf_map[] = {