diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c index d24a7e54..59d08183 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c @@ -725,6 +725,7 @@ static int ether_enable_clks(struct ether_priv_data *pdata) return 0; } +#ifndef OSI_STRIPPED_LIB /** * @brief ether_conf_eee - Init and configure EEE LPI in the MAC * @@ -785,6 +786,7 @@ int ether_conf_eee(struct ether_priv_data *pdata, unsigned int tx_lpi_enable) return ret; } +#endif /* !OSI_STRIPPED_LIB */ /** * @brief Set MGBE MAC_DIV/TX clk rate @@ -860,7 +862,9 @@ static inline void set_speed_work_func(struct work_struct *work) struct net_device *dev = pdata->ndev; struct phy_device *phydev = pdata->phydev; nveu32_t iface_mode = pdata->osi_core->phy_iface_mode; +#ifndef OSI_STRIPPED_LIB unsigned int eee_enable = OSI_DISABLE; +#endif /* !OSI_STRIPPED_LIB */ int speed; int ret = 0; @@ -910,11 +914,13 @@ static inline void set_speed_work_func(struct work_struct *work) ether_set_mgbe_mac_div_rate(pdata->mac_div_clk, pdata->speed); +#ifndef OSI_STRIPPED_LIB if (pdata->eee_enabled && pdata->tx_lpi_enabled) { /* Configure EEE if it is enabled */ eee_enable = OSI_ENABLE; } pdata->eee_active = ether_conf_eee(pdata, eee_enable); +#endif /* !OSI_STRIPPED_LIB */ netif_carrier_on(dev); atomic_set(&pdata->set_speed_ref_cnt, OSI_DISABLE); @@ -972,7 +978,9 @@ static void ether_adjust_link(struct net_device *dev) struct phy_device *phydev = pdata->phydev; int new_state = 0, speed_changed = 0, speed; unsigned long val; +#ifndef OSI_STRIPPED_LIB unsigned int eee_enable = OSI_DISABLE; +#endif /* !OSI_STRIPPED_LIB */ struct osi_ioctl ioctl_data = {}; int ret = 0; @@ -982,6 +990,7 @@ static void ether_adjust_link(struct net_device *dev) cancel_delayed_work_sync(&pdata->set_speed_work); if (phydev->link) { +#ifndef OSI_STRIPPED_LIB if ((pdata->osi_core->pause_frames == OSI_PAUSE_FRAMES_ENABLE) && (phydev->pause || phydev->asym_pause)) { ioctl_data.cmd = OSI_CMD_FLOW_CTRL; @@ -992,6 +1001,7 @@ static void ether_adjust_link(struct net_device *dev) return; } } +#endif /* !OSI_STRIPPED_LIB */ if (pdata->fixed_link == OSI_ENABLE) { if (pdata->osi_core->mac == OSI_MAC_HW_MGBE) { @@ -1003,6 +1013,7 @@ static void ether_adjust_link(struct net_device *dev) phydev->duplex = OSI_FULL_DUPLEX; } } +#ifndef OSI_STRIPPED_LIB if (phydev->duplex != pdata->oldduplex) { new_state = 1; ioctl_data.cmd = OSI_CMD_SET_MODE; @@ -1014,6 +1025,7 @@ static void ether_adjust_link(struct net_device *dev) } pdata->oldduplex = phydev->duplex; } +#endif /* !OSI_STRIPPED_LIB */ if (phydev->speed != pdata->speed) { new_state = 1; @@ -1115,12 +1127,14 @@ static void ether_adjust_link(struct net_device *dev) } } +#ifndef OSI_STRIPPED_LIB /* Configure EEE if it is enabled */ if (pdata->eee_enabled && pdata->tx_lpi_enabled) { eee_enable = OSI_ENABLE; } pdata->eee_active = ether_conf_eee(pdata, eee_enable); +#endif /* !OSI_STRIPPED_LIB */ } /** @@ -1744,7 +1758,7 @@ static void free_rx_dma_resources(struct osi_dma_priv_data *osi_dma, if (rx_ring->rx_swcx != NULL) { ether_free_rx_skbs(rx_ring->rx_swcx, pdata, osi_dma->rx_buf_len, - osi_dma->resv_buf_virt_addr); + pdata->resv_buf_virt_addr); kfree(rx_ring->rx_swcx); } @@ -1960,7 +1974,7 @@ static int ether_allocate_rx_dma_resources(struct osi_dma_priv_data *osi_dma, for (i = 0; i < OSI_MGBE_MAX_NUM_CHANS; i++) { chan = osi_dma->dma_chans[i]; - if (chan != OSI_INVALID_CHAN_NUM) { + if (chan != ETHER_INVALID_CHAN_NUM) { ret = allocate_rx_dma_resource(osi_dma, pdata->dev, chan); if (ret != 0) { @@ -2103,7 +2117,7 @@ static int ether_allocate_tx_dma_resources(struct osi_dma_priv_data *osi_dma, for (i = 0; i < OSI_MGBE_MAX_NUM_CHANS; i++) { chan = osi_dma->dma_chans[i]; - if (chan != OSI_INVALID_CHAN_NUM) { + if (chan != ETHER_INVALID_CHAN_NUM) { ret = allocate_tx_dma_resource(osi_dma, dev, chan); if (ret != 0) { goto exit; @@ -2143,7 +2157,7 @@ static void ether_init_invalid_chan_ring(struct osi_dma_priv_data *osi_dma) } for (i = osi_dma->num_dma_chans; i < OSI_MGBE_MAX_NUM_CHANS; i++) { - osi_dma->dma_chans[i] = OSI_INVALID_CHAN_NUM; + osi_dma->dma_chans[i] = ETHER_INVALID_CHAN_NUM; } } @@ -2165,17 +2179,17 @@ static void free_dma_resources(struct ether_priv_data *pdata) free_rx_dma_resources(osi_dma, pdata); /* unmap reserved DMA*/ - if (osi_dma->resv_buf_phy_addr) { - dma_unmap_single(dev, osi_dma->resv_buf_phy_addr, + if (pdata->resv_buf_phy_addr) { + dma_unmap_single(dev, pdata->resv_buf_phy_addr, osi_dma->rx_buf_len, DMA_FROM_DEVICE); - osi_dma->resv_buf_phy_addr = 0; + pdata->resv_buf_phy_addr = 0; } /* free reserve buffer */ - if (osi_dma->resv_buf_virt_addr) { - dev_kfree_skb_any(osi_dma->resv_buf_virt_addr); - osi_dma->resv_buf_virt_addr = NULL; + if (pdata->resv_buf_virt_addr) { + dev_kfree_skb_any(pdata->resv_buf_virt_addr); + pdata->resv_buf_virt_addr = NULL; } } @@ -2208,11 +2222,11 @@ static int ether_allocate_dma_resources(struct ether_priv_data *pdata) goto error_alloc; } - osi_dma->resv_buf_phy_addr = dma_map_single(pdata->dev, - skb->data, - osi_dma->rx_buf_len, - DMA_FROM_DEVICE); - if (unlikely(dma_mapping_error(pdata->dev, osi_dma->resv_buf_phy_addr) + pdata->resv_buf_phy_addr = dma_map_single(pdata->dev, + skb->data, + osi_dma->rx_buf_len, + DMA_FROM_DEVICE); + if (unlikely(dma_mapping_error(pdata->dev, pdata->resv_buf_phy_addr) != 0)) { dev_err(pdata->dev, "Reserve RX skb dma map failed\n"); ret = -ENOMEM; @@ -2230,7 +2244,7 @@ static int ether_allocate_dma_resources(struct ether_priv_data *pdata) goto error_alloc; } - osi_dma->resv_buf_virt_addr = (void *)skb; + pdata->resv_buf_virt_addr = (void *)skb; return ret; @@ -2238,12 +2252,13 @@ error_alloc: if (skb != NULL) { dev_kfree_skb_any(skb); } - osi_dma->resv_buf_virt_addr = NULL; - osi_dma->resv_buf_phy_addr = 0; + pdata->resv_buf_virt_addr = NULL; + pdata->resv_buf_phy_addr = 0; return ret; } +#ifndef OSI_STRIPPED_LIB /** * @brief Initialize default EEE LPI configurations * @@ -2264,6 +2279,7 @@ static inline void ether_init_eee_params(struct ether_priv_data *pdata) pdata->eee_active = OSI_DISABLE; pdata->tx_lpi_timer = OSI_DEFAULT_TX_LPI_TIMER; } +#endif /* !OSI_STRIPPED_LIB */ /** * @brief function to set unicast/Broadcast MAC address filter @@ -2515,13 +2531,6 @@ static int ether_open(struct net_device *dev) } } - ioctl_data.cmd = OSI_CMD_POLL_FOR_MAC_RST; - ret = osi_handle_ioctl(osi_core, &ioctl_data); - if (ret < 0) { - dev_err(&dev->dev, "failed to poll MAC Software reset\n"); - goto err_poll_swr; - } - ret = ether_mdio_register(pdata); if (ret < 0) { dev_err(&dev->dev, "failed to register MDIO bus\n"); @@ -2602,10 +2611,12 @@ static int ether_open(struct net_device *dev) goto err_hw_init; } +#ifndef OSI_STRIPPED_LIB /* As all registers reset as part of ether_close(), reset private * structure variable as well */ pdata->vlan_hash_filtering = OSI_PERFECT_FILTER_MODE; pdata->l2_filtering_mode = OSI_PERFECT_FILTER_MODE; +#endif /* !OSI_STRIPPED_LIB */ /* Initialize PTP */ ret = ether_ptp_init(pdata); @@ -2628,8 +2639,10 @@ static int ether_open(struct net_device *dev) goto err_r_irq; } +#ifndef OSI_STRIPPED_LIB /* Init EEE configuration */ ether_init_eee_params(pdata); +#endif /* !OSI_STRIPPED_LIB */ /* start PHY */ phy_start(pdata->phydev); @@ -2672,7 +2685,6 @@ err_phy_init: if (pdata->mii != NULL) { mdiobus_unregister(pdata->mii); } -err_poll_swr: err_mdio_reg: if (pdata->xpcs_rst) { reset_control_assert(pdata->xpcs_rst); @@ -2710,14 +2722,18 @@ err_get_sync: static inline void ether_reset_stats(struct ether_priv_data *pdata) { struct osi_core_priv_data *osi_core = pdata->osi_core; +#ifndef OSI_STRIPPED_LIB struct osi_dma_priv_data *osi_dma = pdata->osi_dma; +#endif /* !OSI_STRIPPED_LIB */ memset(&osi_core->mmc, 0U, sizeof(struct osi_mmc_counters)); memset(&pdata->xstats, 0U, sizeof(struct ether_xtra_stat_counters)); +#ifndef OSI_STRIPPED_LIB memset(&osi_dma->dstats, 0U, sizeof(struct osi_xtra_dma_stat_counters)); memset(&osi_dma->pkt_err_stats, 0U, sizeof(struct osi_pkt_err_stats)); +#endif /* !OSI_STRIPPED_LIB */ } /** @@ -3367,6 +3383,7 @@ static int ether_prepare_mc_list(struct net_device *dev, memset(&ioctl_data->l2_filter, 0x0, sizeof(struct osi_filter)); +#ifndef OSI_STRIPPED_LIB if (pdata->l2_filtering_mode == OSI_HASH_FILTER_MODE) { dev_err(pdata->dev, "HASH FILTERING for mc addresses not Supported in SW\n"); @@ -3378,7 +3395,9 @@ static int ether_prepare_mc_list(struct net_device *dev, /* address 0 is used for DUT DA so compare with * pdata->num_mac_addr_regs - 1 */ - } else if (netdev_mc_count(dev) > (pdata->num_mac_addr_regs - 1)) { + } +#endif /* !OSI_STRIPPED_LIB */ + if (netdev_mc_count(dev) > (pdata->num_mac_addr_regs - 1)) { /* switch to PROMISCUOUS mode */ ioctl_data->l2_filter.oper_mode = (OSI_OPER_DIS_PERFECT | OSI_OPER_EN_PROMISC | @@ -3470,6 +3489,7 @@ static int ether_prepare_uc_list(struct net_device *dev, memset(&ioctl_data->l2_filter, 0x0, sizeof(struct osi_filter)); +#ifndef OSI_STRIPPED_LIB if (pdata->l2_filtering_mode == OSI_HASH_FILTER_MODE) { dev_err(pdata->dev, "HASH FILTERING for uc addresses not Supported in SW\n"); @@ -3479,7 +3499,9 @@ static int ether_prepare_uc_list(struct net_device *dev, OSI_OPER_DIS_ALLMULTI); ioctl_data->cmd = OSI_CMD_L2_FILTER; return osi_handle_ioctl(osi_core, ioctl_data); - } else if (netdev_uc_count(dev) > (pdata->num_mac_addr_regs - i)) { + } +#endif /* !OSI_STRIPPED_LIB */ + if (netdev_uc_count(dev) > (pdata->num_mac_addr_regs - i)) { /* switch to PROMISCUOUS mode */ ioctl_data->l2_filter.oper_mode = (OSI_OPER_DIS_PERFECT | OSI_OPER_EN_PROMISC | @@ -4016,6 +4038,7 @@ static int ether_set_features(struct net_device *ndev, netdev_features_t feat) return ret; } +#ifndef OSI_STRIPPED_LIB /** * @brief Adds VLAN ID. This function is invoked by upper * layer when a new VLAN id is registered. This function updates the HW @@ -4103,6 +4126,7 @@ static int ether_vlan_rx_kill_vid(struct net_device *ndev, __be16 vlan_proto, return ret; } +#endif /* !OSI_STRIPPED_LIB */ /** * @brief ether_setup_tc - TC HW offload support @@ -4157,8 +4181,10 @@ static const struct net_device_ops ether_netdev_ops = { .ndo_select_queue = ether_select_queue, .ndo_set_features = ether_set_features, .ndo_set_rx_mode = ether_set_rx_mode, +#ifndef OSI_STRIPPED_LIB .ndo_vlan_rx_add_vid = ether_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = ether_vlan_rx_kill_vid, +#endif /* !OSI_STRIPPED_LIB */ .ndo_setup_tc = ether_setup_tc, }; @@ -4631,7 +4657,7 @@ static int ether_get_mac_address(struct ether_priv_data *pdata) * if there is MGBE controller DT node with index 8 MGBE, * MAC address is at /chosen/nvidia,ether-mac8 */ - if ((pdata->osi_core->mac_ver > OSI_EQOS_MAC_5_10) || + if ((pdata->osi_core->mac_ver > OSI_EQOS_MAC_5_00) || (pdata->osi_core->mac == OSI_MAC_HW_MGBE)) { ret = of_property_read_u32(np, "nvidia,mac-addr-idx", &mac_addr_idx); @@ -5107,8 +5133,10 @@ static int ether_configure_car(struct platform_device *pdev, struct device *dev = pdata->dev; struct device_node *np = dev->of_node; struct osi_core_priv_data *osi_core = pdata->osi_core; +#ifndef OSI_STRIPPED_LIB unsigned long csr_clk_rate = 0; struct osi_ioctl ioctl_data = {}; +#endif /* !OSI_STRIPPED_LIB */ int ret = 0; @@ -5188,6 +5216,7 @@ static int ether_configure_car(struct platform_device *pdev, } } +#ifndef OSI_STRIPPED_LIB csr_clk_rate = clk_get_rate(pdata->axi_cbb_clk); ioctl_data.cmd = OSI_CMD_MDC_CONFIG; ioctl_data.arg5_u64 = csr_clk_rate; @@ -5196,12 +5225,15 @@ static int ether_configure_car(struct platform_device *pdev, dev_err(&pdev->dev, "failed to configure MDC\n"); goto err_mdc; } +#endif /* !OSI_STRIPPED_LIB */ return ret; +#ifndef OSI_STRIPPED_LIB err_mdc: if (pdata->mac_rst) { reset_control_assert(pdata->mac_rst); } +#endif /* !OSI_STRIPPED_LIB */ err_rst: ether_disable_clks(pdata); err_enable_clks: @@ -5229,7 +5261,9 @@ exit: static int ether_init_plat_resources(struct platform_device *pdev, struct ether_priv_data *pdata) { +#ifndef OSI_STRIPPED_LIB bool tegra_hypervisor_mode = is_tegra_hypervisor_mode(); +#endif /* !OSI_STRIPPED_LIB */ struct osi_core_priv_data *osi_core = pdata->osi_core; struct osi_dma_priv_data *osi_dma = pdata->osi_dma; struct resource *res; @@ -5243,6 +5277,7 @@ static int ether_init_plat_resources(struct platform_device *pdev, return PTR_ERR(osi_core->base); } +#ifndef OSI_STRIPPED_LIB if (!tegra_hypervisor_mode) { res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hypervisor"); @@ -5262,6 +5297,7 @@ static int ether_init_plat_resources(struct platform_device *pdev, osi_core->hv_base = NULL; dev_dbg(&pdev->dev, "Hypervisor mode enabled\n"); } +#endif /* !OSI_STRIPPED_LIB */ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dma_base"); @@ -5564,6 +5600,7 @@ static int ether_parse_dt(struct ether_priv_data *pdata) dev_info(dev, "Invalid promiscuous mode - setting supported\n"); pdata->promisc_mode = OSI_ENABLE; } +#ifndef OSI_STRIPPED_LIB /* Read Pause frame feature support */ ret = of_property_read_u32(np, "nvidia,pause_frames", &pdata->osi_core->pause_frames); @@ -5572,6 +5609,7 @@ static int ether_parse_dt(struct ether_priv_data *pdata) " setting to default support as disable\n"); pdata->osi_core->pause_frames = OSI_PAUSE_FRAMES_DISABLE; } +#endif /* !OSI_STRIPPED_LIB */ /* Check if IOMMU is enabled */ if (iommu_get_domain_for_dev(&pdev->dev) != NULL) { @@ -5655,7 +5693,6 @@ static int ether_parse_dt(struct ether_priv_data *pdata) /* Allow to set non zero DMA channel for virtualization */ if (!ether_init_ivc(pdata)) { - osi_dma->use_virtualization = OSI_ENABLE; osi_core->use_virtualization = OSI_ENABLE; dev_info(dev, "Virtualization is enabled\n"); } else { @@ -5697,6 +5734,7 @@ static int ether_parse_dt(struct ether_priv_data *pdata) ETHER_QUEUE_PRIO_DEFAULT, ETHER_QUEUE_PRIO_MAX, osi_core->num_mtl_queues); +#ifndef OSI_STRIPPED_LIB /* Read TX slot enable check array DT node */ ret = of_property_read_u32_array(np, "nvidia,slot_num_check", tmp_value, @@ -5731,6 +5769,7 @@ static int ether_parse_dt(struct ether_priv_data *pdata) } } } +#endif /* !OSI_STRIPPED_LIB */ /* Read Rx Queue - User priority mapping for tagged packets */ ret = of_property_read_u32_array(np, "nvidia,rx-queue-prio", @@ -5804,12 +5843,12 @@ static int ether_parse_dt(struct ether_priv_data *pdata) if (ret < 0) { osi_dma->use_tx_usecs = OSI_DISABLE; } else { - if (osi_dma->tx_usecs > OSI_MAX_TX_COALESCE_USEC || - osi_dma->tx_usecs < OSI_MIN_TX_COALESCE_USEC) { + if (osi_dma->tx_usecs > ETHER_MAX_TX_COALESCE_USEC || + osi_dma->tx_usecs < ETHER_MIN_TX_COALESCE_USEC) { dev_err(dev, "invalid tx_riwt, must be inrange %d to %d\n", - OSI_MIN_TX_COALESCE_USEC, - OSI_MAX_TX_COALESCE_USEC); + ETHER_MIN_TX_COALESCE_USEC, + ETHER_MAX_TX_COALESCE_USEC); return -EINVAL; } osi_dma->use_tx_usecs = OSI_ENABLE; @@ -5821,10 +5860,10 @@ static int ether_parse_dt(struct ether_priv_data *pdata) osi_dma->use_tx_frames = OSI_DISABLE; } else { if (osi_dma->tx_frames > ETHER_TX_MAX_FRAME(osi_dma->tx_ring_sz) || - osi_dma->tx_frames < OSI_MIN_TX_COALESCE_FRAMES) { + osi_dma->tx_frames < ETHER_MIN_TX_COALESCE_FRAMES) { dev_err(dev, "invalid tx-frames, must be inrange %d to %ld", - OSI_MIN_TX_COALESCE_FRAMES, + ETHER_MIN_TX_COALESCE_FRAMES, ETHER_TX_MAX_FRAME(osi_dma->tx_ring_sz)); return -EINVAL; } @@ -5844,21 +5883,21 @@ static int ether_parse_dt(struct ether_priv_data *pdata) osi_dma->use_riwt = OSI_DISABLE; } else { if (osi_dma->mac == OSI_MAC_HW_MGBE && - (osi_dma->rx_riwt > OSI_MAX_RX_COALESCE_USEC || - osi_dma->rx_riwt < OSI_MGBE_MIN_RX_COALESCE_USEC)) { + (osi_dma->rx_riwt > ETHER_MAX_RX_COALESCE_USEC || + osi_dma->rx_riwt < ETHER_MGBE_MIN_RX_COALESCE_USEC)) { dev_err(dev, "invalid rx_riwt, must be inrange %d to %d\n", - OSI_MGBE_MIN_RX_COALESCE_USEC, - OSI_MAX_RX_COALESCE_USEC); + ETHER_MGBE_MIN_RX_COALESCE_USEC, + ETHER_MAX_RX_COALESCE_USEC); return -EINVAL; } else if (osi_dma->mac == OSI_MAC_HW_EQOS && - (osi_dma->rx_riwt > OSI_MAX_RX_COALESCE_USEC || + (osi_dma->rx_riwt > ETHER_MAX_RX_COALESCE_USEC || osi_dma->rx_riwt < - OSI_EQOS_MIN_RX_COALESCE_USEC)) { + ETHER_EQOS_MIN_RX_COALESCE_USEC)) { dev_err(dev, "invalid rx_riwt, must be inrange %d to %d\n", - OSI_EQOS_MIN_RX_COALESCE_USEC, - OSI_MAX_RX_COALESCE_USEC); + ETHER_EQOS_MIN_RX_COALESCE_USEC, + ETHER_MAX_RX_COALESCE_USEC); return -EINVAL; } @@ -5871,10 +5910,10 @@ static int ether_parse_dt(struct ether_priv_data *pdata) osi_dma->use_rx_frames = OSI_DISABLE; } else { if (osi_dma->rx_frames > osi_dma->rx_ring_sz || - osi_dma->rx_frames < OSI_MIN_RX_COALESCE_FRAMES) { + osi_dma->rx_frames < ETHER_MIN_RX_COALESCE_FRAMES) { dev_err(dev, "invalid rx-frames, must be inrange %d to %d", - OSI_MIN_RX_COALESCE_FRAMES, osi_dma->rx_ring_sz); + ETHER_MIN_RX_COALESCE_FRAMES, osi_dma->rx_ring_sz); return -EINVAL; } osi_dma->use_rx_frames = OSI_ENABLE; @@ -5940,8 +5979,10 @@ static int ether_parse_dt(struct ether_priv_data *pdata) } } +#ifndef OSI_STRIPPED_LIB /* Enable VLAN strip by default */ osi_core->strip_vlan_tag = OSI_ENABLE; +#endif ret = ether_parse_phy_dt(pdata, np); if (ret < 0) { @@ -6122,13 +6163,13 @@ static int ether_set_dma_mask(struct ether_priv_data *pdata) */ if (pdata->dma_mask == DMA_MASK_NONE) { switch (pdata->hw_feat.addr_64) { - case OSI_ADDRESS_32BIT: + case ETHER_ADDRESS_32BIT: pdata->dma_mask = DMA_BIT_MASK(32); break; - case OSI_ADDRESS_40BIT: + case ETHER_ADDRESS_40BIT: pdata->dma_mask = DMA_BIT_MASK(40); break; - case OSI_ADDRESS_48BIT: + case ETHER_ADDRESS_48BIT: pdata->dma_mask = DMA_BIT_MASK(48); break; default: @@ -6190,9 +6231,11 @@ static void ether_set_ndev_features(struct net_device *ndev, features |= NETIF_F_HW_VLAN_CTAG_TX; } +#ifndef OSI_STRIPPED_LIB /* Rx VLAN tag stripping/filtering enabled by default */ features |= NETIF_F_HW_VLAN_CTAG_RX; features |= NETIF_F_HW_VLAN_CTAG_FILTER; +#endif /* !OSI_STRIPPED_LIB */ /* Receive Hashing offload */ if (pdata->hw_feat.rss_en) { @@ -6234,6 +6277,7 @@ static void init_filter_values(struct ether_priv_data *pdata) } } +#ifndef OSI_STRIPPED_LIB /** * @brief ether_init_rss - Init OSI RSS structure * @@ -6263,6 +6307,7 @@ static void ether_init_rss(struct ether_priv_data *pdata, for (i = 0; i < OSI_RSS_MAX_TABLE_SIZE; i++) osi_core->rss.table[i] = ethtool_rxfh_indir_default(i, num_q); } +#endif /* !OSI_STRIPPED_LIB */ /** * @brief Ethernet platform driver probe. @@ -6388,30 +6433,22 @@ static int ether_probe(struct platform_device *pdev) goto err_init_res; } - ioctl_data.cmd = OSI_CMD_GET_MAC_VER; - ret = osi_handle_ioctl(osi_core, &ioctl_data); - if (ret < 0) { - dev_err(&pdev->dev, "failed to get MAC version (%u)\n", - osi_core->mac_ver); - goto err_dma_mask; - } - osi_core->mac_ver = ioctl_data.arg1_u32; - - ret = ether_get_mac_address(pdata); - if (ret < 0) { - dev_err(&pdev->dev, "failed to get MAC address\n"); - goto err_dma_mask; - } - ioctl_data.cmd = OSI_CMD_GET_HW_FEAT; ret = osi_handle_ioctl(osi_core, &ioctl_data); if (ret < 0) { dev_err(&pdev->dev, "failed to get HW features\n"); goto err_dma_mask; } + osi_core->mac_ver = ioctl_data.arg1_u32; memcpy(&pdata->hw_feat, &ioctl_data.hw_feat, sizeof(struct osi_hw_features)); + ret = ether_get_mac_address(pdata); + if (ret < 0) { + dev_err(&pdev->dev, "failed to get MAC address\n"); + goto err_dma_mask; + } + ret = ether_set_dma_mask(pdata); if (ret < 0) { dev_err(&pdev->dev, "failed to set dma mask\n"); @@ -6430,8 +6467,10 @@ static int ether_probe(struct platform_device *pdev) /* Set netdev features based on hw features */ ether_set_ndev_features(ndev, pdata); +#ifndef OSI_STRIPPED_LIB /* RSS init */ ether_init_rss(pdata, ndev->features); +#endif /* !OSI_STRIPPED_LIB */ ret = ether_get_irqs(pdev, pdata, num_dma_chans); if (ret < 0) { @@ -6659,13 +6698,6 @@ static int ether_resume(struct ether_priv_data *pdata) } } - ioctl_data.cmd = OSI_CMD_POLL_FOR_MAC_RST; - ret = osi_handle_ioctl(osi_core, &ioctl_data); - if (ret < 0) { - dev_err(dev, "failed to poll mac software reset\n"); - return ret; - } - if (pdata->xpcs_rst) { ret = reset_control_reset(pdata->xpcs_rst); if (ret < 0) { diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.h b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.h index 9d9c123e..0d1f5883 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.h +++ b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.h @@ -218,7 +218,26 @@ */ #define FIXED_PHY_INVALID_MDIO_ADDR 0xFFU +#define ETHER_ADDRESS_32BIT 0 +#define ETHER_ADDRESS_40BIT 1 +#define ETHER_ADDRESS_48BIT 2 +/** + * @addtogroup coalesce defines + * + * @brief Used to configure coalesce. + * @{ + */ +#define ETHER_MIN_TX_COALESCE_USEC 32U +#define ETHER_MIN_TX_COALESCE_FRAMES 1U +#define ETHER_MAX_TX_COALESCE_USEC 1020U +#define ETHER_MIN_RX_COALESCE_FRAMES 1U +#define ETHER_MAX_RX_COALESCE_USEC 1020U +#define ETHER_EQOS_MIN_RX_COALESCE_USEC 5U +#define ETHER_MGBE_MIN_RX_COALESCE_USEC 6U +/** @} */ + +#define ETHER_INVALID_CHAN_NUM 0xFFU /** * @brief Check if Tx data buffer length is within bounds. * @@ -393,6 +412,10 @@ struct ether_priv_data { struct osi_core_priv_data *osi_core; /** OSI DMA private data */ struct osi_dma_priv_data *osi_dma; + /** Virtual address of reserved DMA buffer */ + void *resv_buf_virt_addr; + /** Physical address of reserved DMA buffer */ + nveu64_t resv_buf_phy_addr; /** HW supported feature list */ struct osi_hw_features hw_feat; /** Array of DMA Transmit channel NAPI */ @@ -695,7 +718,9 @@ int ether_handle_hwtstamp_ioctl(struct ether_priv_data *pdata, struct ifreq *ifr); int ether_handle_priv_ts_ioctl(struct ether_priv_data *pdata, struct ifreq *ifr); +#ifndef OSI_STRIPPED_LIB int ether_conf_eee(struct ether_priv_data *pdata, unsigned int tx_lpi_enable); +#endif /* !OSI_STRIPPED_LIB */ /** * @brief ether_padctrl_mii_rx_pins - Enable/Disable RGMII Rx pins. @@ -708,10 +733,25 @@ int ether_conf_eee(struct ether_priv_data *pdata, unsigned int tx_lpi_enable); */ int ether_padctrl_mii_rx_pins(void *priv, unsigned int enable); +#ifndef OSI_STRIPPED_LIB void ether_selftest_run(struct net_device *dev, struct ethtool_test *etest, u64 *buf); void ether_selftest_get_strings(struct ether_priv_data *pdata, u8 *data); int ether_selftest_get_count(struct ether_priv_data *pdata); +#else +static inline void ether_selftest_run(struct net_device *dev, + struct ethtool_test *etest, u64 *buf) +{ +} +static inline void ether_selftest_get_strings(struct ether_priv_data *pdata, + u8 *data) +{ +} +static inline int ether_selftest_get_count(struct ether_priv_data *pdata) +{ + return -EOPNOTSUPP; +} +#endif /* CONFIG_NVETHERNET_SELFTESTS */ /** * @brief ether_assign_osd_ops - Assigns OSD ops for OSI diff --git a/drivers/net/ethernet/nvidia/nvethernet/ethtool.c b/drivers/net/ethernet/nvidia/nvethernet/ethtool.c index 83ddad0a..96dbd666 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ethtool.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ethtool.c @@ -26,6 +26,7 @@ struct ether_stats { size_t stat_offset; }; +#ifndef OSI_STRIPPED_LIB /** * @brief Name of FRP statistics, with length of name not more than * ETH_GSTRING_LEN @@ -137,6 +138,7 @@ static const struct ether_stats ether_dstrings_stats[] = { * @brief Ethernet extra DMA statistics array length */ #define ETHER_EXTRA_DMA_STAT_LEN OSI_ARRAY_SIZE(ether_dstrings_stats) +#endif /* OSI_STRIPPED_LIB */ /** * @brief Name of extra Ethernet stats, with length of name not more than @@ -427,6 +429,7 @@ static const struct ether_stats ether_tstrings_stats[] = { ETHER_CORE_STATS(base_time_reg_err), ETHER_CORE_STATS(sw_own_list_complete), +#ifndef OSI_STRIPPED_LIB /* Tx/Rx IRQ error info */ ETHER_CORE_STATS(tx_proc_stopped_irq_n[0]), ETHER_CORE_STATS(tx_proc_stopped_irq_n[1]), @@ -478,6 +481,7 @@ static const struct ether_stats ether_tstrings_stats[] = { ETHER_CORE_STATS(mgbe_jabber_timeout_err), ETHER_CORE_STATS(mgbe_payload_cs_err), ETHER_CORE_STATS(mgbe_tx_underflow_err), +#endif /* OSI_STRIPPED_LIB */ }; /** @@ -498,7 +502,9 @@ static void ether_get_ethtool_stats(struct net_device *dev, { struct ether_priv_data *pdata = netdev_priv(dev); struct osi_core_priv_data *osi_core = pdata->osi_core; +#ifndef OSI_STRIPPED_LIB struct osi_dma_priv_data *osi_dma = pdata->osi_dma; +#endif /* OSI_STRIPPED_LIB */ struct osi_ioctl ioctl_data = {}; int i, j = 0; int ret; @@ -542,6 +548,7 @@ static void ether_get_ethtool_stats(struct net_device *dev, sizeof(u64)) ? (*(u64 *)p) : (*(u32 *)p); } +#ifndef OSI_STRIPPED_LIB for (i = 0; i < ETHER_EXTRA_DMA_STAT_LEN; i++) { char *p = (char *)osi_dma + ether_dstrings_stats[i].stat_offset; @@ -558,14 +565,6 @@ static void ether_get_ethtool_stats(struct net_device *dev, sizeof(u64)) ? (*(u64 *)p) : (*(u32 *)p); } - for (i = 0; i < ETHER_CORE_STAT_LEN; i++) { - char *p = (char *)osi_core + - ether_tstrings_stats[i].stat_offset; - - data[j++] = (ether_tstrings_stats[i].sizeof_stat == - sizeof(u64)) ? (*(u64 *)p) : (*(u32 *)p); - } - for (i = 0; ((i < ETHER_FRP_STAT_LEN) && (pdata->hw_feat.frp_sel == OSI_ENABLE)); i++) { char *p = (char *)osi_dma + @@ -574,6 +573,15 @@ static void ether_get_ethtool_stats(struct net_device *dev, data[j++] = (ether_frpstrings_stats[i].sizeof_stat == sizeof(u64)) ? (*(u64 *)p) : (*(u32 *)p); } +#endif /* OSI_STRIPPED_LIB */ + + for (i = 0; i < ETHER_CORE_STAT_LEN; i++) { + char *p = (char *)osi_core + + ether_tstrings_stats[i].stat_offset; + + data[j++] = (ether_tstrings_stats[i].sizeof_stat == + sizeof(u64)) ? (*(u64 *)p) : (*(u32 *)p); + } } } @@ -607,6 +615,7 @@ static int ether_get_sset_count(struct net_device *dev, int sset) } else { len += ETHER_EXTRA_STAT_LEN; } +#ifndef OSI_STRIPPED_LIB if (INT_MAX - ETHER_EXTRA_DMA_STAT_LEN < len) { /* do nothing */ } else { @@ -617,11 +626,6 @@ static int ether_get_sset_count(struct net_device *dev, int sset) } else { len += ETHER_PKT_ERR_STAT_LEN; } - if (INT_MAX - ETHER_CORE_STAT_LEN < len) { - /* do nothing */ - } else { - len += ETHER_CORE_STAT_LEN; - } if (INT_MAX - ETHER_FRP_STAT_LEN < len) { /* do nothing */ } else { @@ -629,6 +633,12 @@ static int ether_get_sset_count(struct net_device *dev, int sset) len += ETHER_FRP_STAT_LEN; } } +#endif /* OSI_STRIPPED_LIB */ + if (INT_MAX - ETHER_CORE_STAT_LEN < len) { + /* do nothing */ + } else { + len += ETHER_CORE_STAT_LEN; + } } else if (sset == ETH_SS_TEST) { len = ether_selftest_get_count(pdata); } else { @@ -676,6 +686,7 @@ static void ether_get_strings(struct net_device *dev, u32 stringset, u8 *data) } p += ETH_GSTRING_LEN; } +#ifndef OSI_STRIPPED_LIB for (i = 0; i < ETHER_EXTRA_DMA_STAT_LEN; i++) { str = (u8 *)ether_dstrings_stats[i].stat_string; if (memcpy(p, str, ETH_GSTRING_LEN) == @@ -692,14 +703,6 @@ static void ether_get_strings(struct net_device *dev, u32 stringset, u8 *data) } p += ETH_GSTRING_LEN; } - for (i = 0; i < ETHER_CORE_STAT_LEN; i++) { - str = (u8 *)ether_tstrings_stats[i].stat_string; - if (memcpy(p, str, ETH_GSTRING_LEN) == - OSI_NULL) { - return; - } - p += ETH_GSTRING_LEN; - } for (i = 0; ((i < ETHER_FRP_STAT_LEN) && (pdata->hw_feat.frp_sel == OSI_ENABLE)); i++) { @@ -711,6 +714,15 @@ static void ether_get_strings(struct net_device *dev, u32 stringset, u8 *data) } p += ETH_GSTRING_LEN; } +#endif /* OSI_STRIPPED_LIB */ + for (i = 0; i < ETHER_CORE_STAT_LEN; i++) { + str = (u8 *)ether_tstrings_stats[i].stat_string; + if (memcpy(p, str, ETH_GSTRING_LEN) == + OSI_NULL) { + return; + } + p += ETH_GSTRING_LEN; + } } } else if (stringset == (u32)ETH_SS_TEST) { ether_selftest_get_strings(pdata, p); @@ -719,6 +731,7 @@ static void ether_get_strings(struct net_device *dev, u32 stringset, u8 *data) } } +#ifndef OSI_STRIPPED_LIB /** * @brief Get pause frame settings * @@ -833,6 +846,7 @@ static int ether_set_pauseparam(struct net_device *ndev, return ret; } +#endif /* OSI_STRIPPED_LIB */ /** * @brief Get HW supported time stamping. @@ -931,10 +945,10 @@ static int ether_set_coalesce(struct net_device *dev, if (ec->tx_max_coalesced_frames == OSI_DISABLE) { osi_dma->use_tx_frames = OSI_DISABLE; } else if ((ec->tx_max_coalesced_frames > ETHER_TX_MAX_FRAME(osi_dma->tx_ring_sz)) || - (ec->tx_max_coalesced_frames < OSI_MIN_TX_COALESCE_FRAMES)) { + (ec->tx_max_coalesced_frames < ETHER_MIN_TX_COALESCE_FRAMES)) { netdev_err(dev, "invalid tx-frames, must be in the range of" - " %d to %ld frames\n", OSI_MIN_TX_COALESCE_FRAMES, + " %d to %ld frames\n", ETHER_MIN_TX_COALESCE_FRAMES, ETHER_TX_MAX_FRAME(osi_dma->tx_ring_sz)); return -EINVAL; } else { @@ -943,12 +957,12 @@ static int ether_set_coalesce(struct net_device *dev, if (ec->tx_coalesce_usecs == OSI_DISABLE) { osi_dma->use_tx_usecs = OSI_DISABLE; - } else if ((ec->tx_coalesce_usecs > OSI_MAX_TX_COALESCE_USEC) || - (ec->tx_coalesce_usecs < OSI_MIN_TX_COALESCE_USEC)) { + } else if ((ec->tx_coalesce_usecs > ETHER_MAX_TX_COALESCE_USEC) || + (ec->tx_coalesce_usecs < ETHER_MIN_TX_COALESCE_USEC)) { netdev_err(dev, "invalid tx_usecs, must be in a range of" - " %d to %d usec\n", OSI_MIN_TX_COALESCE_USEC, - OSI_MAX_TX_COALESCE_USEC); + " %d to %d usec\n", ETHER_MIN_TX_COALESCE_USEC, + ETHER_MAX_TX_COALESCE_USEC); return -EINVAL; } else { osi_dma->use_tx_usecs = OSI_ENABLE; @@ -963,10 +977,10 @@ static int ether_set_coalesce(struct net_device *dev, if (ec->rx_max_coalesced_frames == OSI_DISABLE) { osi_dma->use_rx_frames = OSI_DISABLE; } else if ((ec->rx_max_coalesced_frames > osi_dma->rx_ring_sz) || - (ec->rx_max_coalesced_frames < OSI_MIN_RX_COALESCE_FRAMES)) { + (ec->rx_max_coalesced_frames < ETHER_MIN_RX_COALESCE_FRAMES)) { netdev_err(dev, "invalid rx-frames, must be in the range of" - " %d to %d frames\n", OSI_MIN_RX_COALESCE_FRAMES, + " %d to %d frames\n", ETHER_MIN_RX_COALESCE_FRAMES, osi_dma->rx_ring_sz); return -EINVAL; } else { @@ -976,20 +990,20 @@ static int ether_set_coalesce(struct net_device *dev, if (ec->rx_coalesce_usecs == OSI_DISABLE) { osi_dma->use_riwt = OSI_DISABLE; } else if (osi_dma->mac == OSI_MAC_HW_EQOS && - (ec->rx_coalesce_usecs > OSI_MAX_RX_COALESCE_USEC || - ec->rx_coalesce_usecs < OSI_EQOS_MIN_RX_COALESCE_USEC)) { + (ec->rx_coalesce_usecs > ETHER_MAX_RX_COALESCE_USEC || + ec->rx_coalesce_usecs < ETHER_EQOS_MIN_RX_COALESCE_USEC)) { netdev_err(dev, "invalid rx_usecs, must be in a range of %d to %d usec\n", - OSI_EQOS_MIN_RX_COALESCE_USEC, - OSI_MAX_RX_COALESCE_USEC); + ETHER_EQOS_MIN_RX_COALESCE_USEC, + ETHER_MAX_RX_COALESCE_USEC); return -EINVAL; } else if (osi_dma->mac == OSI_MAC_HW_MGBE && - (ec->rx_coalesce_usecs > OSI_MAX_RX_COALESCE_USEC || - ec->rx_coalesce_usecs < OSI_MGBE_MIN_RX_COALESCE_USEC)) { + (ec->rx_coalesce_usecs > ETHER_MAX_RX_COALESCE_USEC || + ec->rx_coalesce_usecs < ETHER_MGBE_MIN_RX_COALESCE_USEC)) { netdev_err(dev, "invalid rx_usecs, must be in a range of %d to %d usec\n", - OSI_MGBE_MIN_RX_COALESCE_USEC, - OSI_MAX_RX_COALESCE_USEC); + ETHER_MGBE_MIN_RX_COALESCE_USEC, + ETHER_MAX_RX_COALESCE_USEC); return -EINVAL; } else { osi_dma->use_riwt = OSI_ENABLE; @@ -1057,6 +1071,7 @@ static int ether_get_coalesce(struct net_device *dev, return 0; } +#ifndef OSI_STRIPPED_LIB /* * @brief Get current EEE configuration in MAC/PHY * @@ -1572,6 +1587,7 @@ static void ether_set_msglevel(struct net_device *ndev, u32 level) pdata->msg_enable = level; } +#endif /* OSI_STRIPPED_LIB */ /** * @brief Set of ethtool operations @@ -1580,8 +1596,6 @@ static const struct ethtool_ops ether_ethtool_ops = { .get_link = ethtool_op_get_link, .get_link_ksettings = phy_ethtool_get_link_ksettings, .set_link_ksettings = phy_ethtool_set_link_ksettings, - .get_pauseparam = ether_get_pauseparam, - .set_pauseparam = ether_set_pauseparam, .get_ts_info = ether_get_ts_info, .get_strings = ether_get_strings, .get_ethtool_stats = ether_get_ethtool_stats, @@ -1590,12 +1604,15 @@ static const struct ethtool_ops ether_ethtool_ops = { .supported_coalesce_params = (ETHTOOL_COALESCE_USECS | ETHTOOL_COALESCE_MAX_FRAMES), .set_coalesce = ether_set_coalesce, +#ifndef OSI_STRIPPED_LIB .get_wol = ether_get_wol, .set_wol = ether_set_wol, - .get_eee = ether_get_eee, - .set_eee = ether_set_eee, .self_test = ether_selftest_run, .get_rxnfc = ether_get_rxnfc, + .get_pauseparam = ether_get_pauseparam, + .set_pauseparam = ether_set_pauseparam, + .get_eee = ether_get_eee, + .set_eee = ether_set_eee, .get_rxfh_key_size = ether_get_rxfh_key_size, .get_rxfh_indir_size = ether_get_rxfh_indir_size, .get_rxfh = ether_get_rxfh, @@ -1604,6 +1621,7 @@ static const struct ethtool_ops ether_ethtool_ops = { .set_ringparam = ether_set_ringparam, .get_msglevel = ether_get_msglevel, .set_msglevel = ether_set_msglevel, +#endif /* OSI_STRIPPED_LIB */ }; void ether_set_ethtool_ops(struct net_device *ndev) diff --git a/drivers/net/ethernet/nvidia/nvethernet/ioctl.c b/drivers/net/ethernet/nvidia/nvethernet/ioctl.c index 09ef14d7..c3614fad 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ioctl.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ioctl.c @@ -3,94 +3,6 @@ #include "ether_linux.h" -/** - * @brief Function to check valid ip4 address - * - * Algorithm: - * 1) Check if IP4 address provided is valid. - * - * @param[in] ip_addr: Pointer to ip4 addr buffer. - * - * @retval true If valid ip4 address - * @retval false Otherwise - */ -static bool ether_is_ip4_addr(unsigned char *ip_addr) -{ - unsigned char addr; - bool is_ip4_addr = false; - - if (ip_addr == NULL) { - return is_ip4_addr; - } - addr = (ip_addr[0] & MAX_IP_ADDR_BYTE); - /* class E ip address reserved for future use - */ - if (addr >= CLASS_E_IP4_ADDR_RANGE_START) { - is_ip4_addr = false; - } else { - is_ip4_addr = true; - } - return is_ip4_addr; -} - -/** - * @brief Function to check valid multicast address - * - * Algorithm: - * 1) Check if multicast address provided is valid. - * - * @param[in] ip_addr: Pointer to multicast addr buffer. - * - * @retval true If valid multicast address - * @retval false Otherwise - */ -static bool ether_is_mc_addr(unsigned char *mc_addr) -{ - unsigned char addr; - bool is_mc_addr = false; - - if (mc_addr == NULL) { - return is_mc_addr; - } - addr = (mc_addr[0] & MAX_IP_ADDR_BYTE); - /* class D ip address reserved for multicast address - */ - if (addr >= MIN_MC_ADDR_RANGE && addr <= MAX_MC_ADDR_RANGE) { - is_mc_addr = true; - } else { - is_mc_addr = false; - } - return is_mc_addr; -} - -/** - * @brief Function to check valid broadcast address - * - * Algorithm: - * 1) Check if broadcast address provided is valid. - * - * @param[in] bc_addr: Pointer to broadcast addr buffer. - * - * @retval true If valid broadcast address - * @retval false Otherwise - */ -static bool ether_is_bc_addr(unsigned char *bc_addr) -{ - bool is_bc_addr = true; - int i; - - if (bc_addr == NULL) { - return false; - } - for (i = 0; i < NUM_BYTES_IN_IPADDR; i++) { - if (bc_addr[i] != MAX_IP_ADDR_BYTE) { - is_bc_addr = false; - break; - } - } - return is_bc_addr; -} - /** * @brief Function to handle private ioctl - EQOS_AVB_ALGORITHM * @@ -109,8 +21,10 @@ static int ether_set_avb_algo(struct net_device *ndev, { struct ether_priv_data *pdata = netdev_priv(ndev); struct osi_core_priv_data *osi_core = pdata->osi_core; +#ifndef OSI_STRIPPED_LIB struct osi_dma_priv_data *osi_dma = pdata->osi_dma; struct osi_tx_ring *tx_ring = NULL; +#endif /* !OSI_STRIPPED_LIB */ struct osi_ioctl ioctl_data = {}; int ret = -1; @@ -133,6 +47,7 @@ static int ether_set_avb_algo(struct net_device *ndev, return -EINVAL; } +#ifndef OSI_STRIPPED_LIB /* Check AVB mode disable on slot function enable */ tx_ring = osi_dma->tx_ring[ioctl_data.avb.qindex]; if (tx_ring && tx_ring->slot_check == OSI_ENABLE && @@ -142,6 +57,7 @@ static int ether_set_avb_algo(struct net_device *ndev, ioctl_data.avb.qindex); return -EINVAL; } +#endif /* !OSI_STRIPPED_LIB */ ioctl_data.cmd = OSI_CMD_SET_AVB; return osi_handle_ioctl(osi_core, &ioctl_data); @@ -290,6 +206,7 @@ static int ether_get_avb_algo(struct net_device *ndev, return ret; } +#ifndef OSI_STRIPPED_LIB /** * @brief Handle ioctl to enable/disable PTP offload * @@ -376,6 +293,94 @@ static int ether_config_ptp_offload(struct ether_priv_data *pdata, return ret; } +/** + * @brief Function to check valid ip4 address + * + * Algorithm: + * 1) Check if IP4 address provided is valid. + * + * @param[in] ip_addr: Pointer to ip4 addr buffer. + * + * @retval true If valid ip4 address + * @retval false Otherwise + */ +static bool ether_is_ip4_addr(unsigned char *ip_addr) +{ + unsigned char addr; + bool is_ip4_addr = false; + + if (ip_addr == NULL) { + return is_ip4_addr; + } + addr = (ip_addr[0] & MAX_IP_ADDR_BYTE); + /* class E ip address reserved for future use + */ + if (addr >= CLASS_E_IP4_ADDR_RANGE_START) { + is_ip4_addr = false; + } else { + is_ip4_addr = true; + } + return is_ip4_addr; +} + +/** + * @brief Function to check valid multicast address + * + * Algorithm: + * 1) Check if multicast address provided is valid. + * + * @param[in] ip_addr: Pointer to multicast addr buffer. + * + * @retval true If valid multicast address + * @retval false Otherwise + */ +static bool ether_is_mc_addr(unsigned char *mc_addr) +{ + unsigned char addr; + bool is_mc_addr = false; + + if (mc_addr == NULL) { + return is_mc_addr; + } + addr = (mc_addr[0] & MAX_IP_ADDR_BYTE); + /* class D ip address reserved for multicast address + */ + if (addr >= MIN_MC_ADDR_RANGE && addr <= MAX_MC_ADDR_RANGE) { + is_mc_addr = true; + } else { + is_mc_addr = false; + } + return is_mc_addr; +} + +/** + * @brief Function to check valid broadcast address + * + * Algorithm: + * 1) Check if broadcast address provided is valid. + * + * @param[in] bc_addr: Pointer to broadcast addr buffer. + * + * @retval true If valid broadcast address + * @retval false Otherwise + */ +static bool ether_is_bc_addr(unsigned char *bc_addr) +{ + bool is_bc_addr = true; + int i; + + if (bc_addr == NULL) { + return false; + } + for (i = 0; i < NUM_BYTES_IN_IPADDR; i++) { + if (bc_addr[i] != MAX_IP_ADDR_BYTE) { + is_bc_addr = false; + break; + } + } + return is_bc_addr; +} + /** * @brief Handle ioctl to enable/disable ARP offload * @@ -429,6 +434,7 @@ static int ether_config_arp_offload(struct ether_priv_data *pdata, ret ? "Failed" : "Success"); return ret; } +#endif /* !OSI_STRIPPED_LIB */ /** * @brief This function is invoked by ioctl function when user issues an ioctl @@ -589,6 +595,7 @@ static int ether_config_l2_filters(struct net_device *dev, return osi_handle_ioctl(osi_core, &ioctl_data); } +#ifndef OSI_STRIPPED_LIB /** * @brief This function is invoked by ioctl functio when user issues an ioctl * command to configure VALN filtering. @@ -896,6 +903,7 @@ static int ether_config_ptp_rxq(struct net_device *ndev, ioctl_data.cmd = OSI_CMD_PTP_RXQ_ROUTE; return osi_handle_ioctl(osi_core, &ioctl_data); } +#endif /* !OSI_STRIPPED_LIB */ /** * @brief This function is invoked by ioctl function when user issues an ioctl @@ -1050,14 +1058,16 @@ int ether_handle_priv_ioctl(struct net_device *ndev, struct ifreq *ifr) { struct ether_priv_data *pdata = netdev_priv(ndev); +#ifndef OSI_STRIPPED_LIB struct phy_device *phydev = ndev->phydev; - struct ether_exported_ifr_data ifdata; + struct osi_ioctl ioctl_data = {}; struct osi_core_priv_data *osi_core = pdata->osi_core; +#endif /* !OSI_STRIPPED_LIB */ + struct ether_exported_ifr_data ifdata; #ifdef OSI_DEBUG struct osi_dma_priv_data *osi_dma = pdata->osi_dma; #endif int ret = -EOPNOTSUPP; - struct osi_ioctl ioctl_data = {}; if (copy_from_user(&ifdata, (void __user *)ifr->ifr_data, sizeof(ifdata)) != 0U) { @@ -1088,6 +1098,7 @@ int ether_handle_priv_ioctl(struct net_device *ndev, } switch (ifdata.ifcmd) { +#ifndef OSI_STRIPPED_LIB case EQOS_GET_TX_QCNT: ifdata.qinx = osi_core->num_mtl_queues; ret = 0; @@ -1106,12 +1117,14 @@ int ether_handle_priv_ioctl(struct net_device *ndev, } ret = 0; break; +#endif /* !OSI_STRIPPED_LIB */ case ETHER_AVB_ALGORITHM: ret = ether_set_avb_algo(ndev, &ifdata); break; case ETHER_GET_AVB_ALGORITHM: ret = ether_get_avb_algo(ndev, &ifdata); break; +#ifndef OSI_STRIPPED_LIB case ETHER_CONFIG_ARP_OFFLOAD: ret = ether_config_arp_offload(pdata, &ifdata); break; @@ -1126,6 +1139,35 @@ int ether_handle_priv_ioctl(struct net_device *ndev, ret = -EOPNOTSUPP; } break; + case ETHER_CONFIG_LOOPBACK_MODE: + ret = ether_config_loopback_mode(ndev, ifdata.if_flags); + break; + case EQOS_VLAN_FILTERING_CMD: + ret = ether_config_vlan_filter(ndev, &ifdata); + break; + case ETHER_PAD_CALIBRATION: + ret = ether_pad_calibration(ndev, ifdata.if_flags); + break; + case EQOS_L2_DA_FILTERING_CMD: + ret = ether_config_l2_da_filter(ndev, &ifdata); + break; + case ETHER_MC_DMA_ROUTE: + ret = ether_config_mc_dmasel(ndev, ifdata.if_flags); + break; + case ETHER_READ_REG: + ioctl_data.cmd = OSI_CMD_READ_REG; + ioctl_data.arg1_u32 = ifdata.if_flags; + ret = osi_handle_ioctl(osi_core, &ioctl_data); + ifdata.qinx = ret; + break; + case ETHER_WRITE_REG: + ioctl_data.cmd = OSI_CMD_WRITE_REG; + ioctl_data.arg1_u32 = ifdata.qinx; + ioctl_data.arg2_u32 = ifdata.if_flags; + ret = osi_handle_ioctl(osi_core, &ioctl_data); + ifdata.qinx = ret; + break; +#endif /* !OSI_STRIPPED_LIB */ case EQOS_L3L4_FILTER_CMD: /* flags should be 0x0 or 0x1, discard any other */ if (pdata->hw_feat.l3l4_filter_num > 0U) { @@ -1143,40 +1185,12 @@ int ether_handle_priv_ioctl(struct net_device *ndev, case ETHER_CONFIG_FRP_CMD: ret = ether_config_frp_cmd(ndev, &ifdata); break; - case EQOS_VLAN_FILTERING_CMD: - ret = ether_config_vlan_filter(ndev, &ifdata); - break; - case EQOS_L2_DA_FILTERING_CMD: - ret = ether_config_l2_da_filter(ndev, &ifdata); - break; - case ETHER_MC_DMA_ROUTE: - ret = ether_config_mc_dmasel(ndev, ifdata.if_flags); - break; - case ETHER_CONFIG_LOOPBACK_MODE: - ret = ether_config_loopback_mode(ndev, ifdata.if_flags); - break; case ETHER_CONFIG_EST: ret = ether_config_est(ndev, &ifdata); break; case ETHER_CONFIG_FPE: ret = ether_config_fpe(ndev, &ifdata); break; - case ETHER_READ_REG: - ioctl_data.cmd = OSI_CMD_READ_REG; - ioctl_data.arg1_u32 = ifdata.if_flags; - ret = osi_handle_ioctl(pdata->osi_core, &ioctl_data); - ifdata.qinx = ret; - break; - case ETHER_WRITE_REG: - ioctl_data.cmd = OSI_CMD_WRITE_REG; - ioctl_data.arg1_u32 = ifdata.qinx; - ioctl_data.arg2_u32 = ifdata.if_flags; - ret = osi_handle_ioctl(pdata->osi_core, &ioctl_data); - ifdata.qinx = ret; - break; - case ETHER_PAD_CALIBRATION: - ret = ether_pad_calibration(ndev, ifdata.if_flags); - break; #ifdef OSI_DEBUG case ETHER_REGISTER_DUMP: osi_dma->ioctl_data.cmd = OSI_DMA_IOCTL_CMD_REG_DUMP; @@ -1185,7 +1199,7 @@ int ether_handle_priv_ioctl(struct net_device *ndev, goto err; ioctl_data.cmd = OSI_CMD_REG_DUMP; - ret = osi_handle_ioctl(pdata->osi_core, &ioctl_data); + ret = osi_handle_ioctl(osi_core, &ioctl_data); break; case ETHER_STRUCTURE_DUMP: osi_dma->ioctl_data.cmd = OSI_DMA_IOCTL_CMD_STRUCTS_DUMP; @@ -1194,7 +1208,7 @@ int ether_handle_priv_ioctl(struct net_device *ndev, goto err; ioctl_data.cmd = OSI_CMD_STRUCTS_DUMP; - ret = osi_handle_ioctl(pdata->osi_core, &ioctl_data); + ret = osi_handle_ioctl(osi_core, &ioctl_data); break; case ETHER_DEBUG_INTR_CONFIG: ret = ether_debug_intr_config(ndev, &ifdata); diff --git a/drivers/net/ethernet/nvidia/nvethernet/osd.c b/drivers/net/ethernet/nvidia/nvethernet/osd.c index 598ac757..dfc9f642 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/osd.c +++ b/drivers/net/ethernet/nvidia/nvethernet/osd.c @@ -145,11 +145,13 @@ static void osd_log(void *priv, "[%s][%d][type:0x%x][loga-0x%llx] %s", func, line, type, loga, err); break; +#ifndef OSI_STRIPPED_LIB case OSI_LOG_WARN: dev_warn(((struct ether_priv_data *)priv)->dev, "[%s][%d][type:0x%x][loga-0x%llx] %s", func, line, type, loga, err); break; +#endif /* !OSI_STRIPPED_LIB */ case OSI_LOG_ERR: dev_err(((struct ether_priv_data *)priv)->dev, "[%s][%d][type:0x%x][loga-0x%llx] %s", @@ -165,10 +167,12 @@ static void osd_log(void *priv, pr_info("[%s][%d][type:0x%x][loga-0x%llx] %s", func, line, type, loga, err); break; +#ifndef OSI_STRIPPED_LIB case OSI_LOG_WARN: pr_warn("[%s][%d][type:0x%x][loga-0x%llx] %s", func, line, type, loga, err); break; +#endif /* !OSI_STRIPPED_LIB */ case OSI_LOG_ERR: pr_err("[%s][%d][type:0x%x][loga-0x%llx] %s", func, line, type, loga, err); @@ -204,7 +208,7 @@ static inline int ether_alloc_skb(struct ether_priv_data *pdata, unsigned long val; if (((rx_swcx->flags & OSI_RX_SWCX_REUSE) == OSI_RX_SWCX_REUSE) && - (rx_swcx->buf_virt_addr != pdata->osi_dma->resv_buf_virt_addr)) { + (rx_swcx->buf_virt_addr != pdata->resv_buf_virt_addr)) { /* Skip buffer allocation and DMA mapping since * PTP software context will have valid buffer and * DMA addresses so use them as is. @@ -218,8 +222,8 @@ static inline int ether_alloc_skb(struct ether_priv_data *pdata, if (unlikely(skb == NULL)) { dev_err(pdata->dev, "RX skb allocation failed, using reserved buffer\n"); - rx_swcx->buf_virt_addr = pdata->osi_dma->resv_buf_virt_addr; - rx_swcx->buf_phy_addr = pdata->osi_dma->resv_buf_phy_addr; + rx_swcx->buf_virt_addr = pdata->resv_buf_virt_addr; + rx_swcx->buf_phy_addr = pdata->resv_buf_phy_addr; rx_swcx->flags |= OSI_RX_SWCX_BUF_VALID; val = pdata->xstats.re_alloc_rxbuf_failed[chan]; pdata->xstats.re_alloc_rxbuf_failed[chan] = @@ -240,8 +244,8 @@ static inline int ether_alloc_skb(struct ether_priv_data *pdata, if (!rx_swcx->buf_virt_addr) { dev_err(pdata->dev, "page pool allocation failed using resv_buf\n"); - rx_swcx->buf_virt_addr = pdata->osi_dma->resv_buf_virt_addr; - rx_swcx->buf_phy_addr = pdata->osi_dma->resv_buf_phy_addr; + rx_swcx->buf_virt_addr = pdata->resv_buf_virt_addr; + rx_swcx->buf_phy_addr = pdata->resv_buf_phy_addr; rx_swcx->flags |= OSI_RX_SWCX_BUF_VALID; val = pdata->xstats.re_alloc_rxbuf_failed[chan]; pdata->xstats.re_alloc_rxbuf_failed[chan] = @@ -620,13 +624,25 @@ static void osd_receive_packet(void *priv, struct osi_rx_ring *rx_ring, #endif dma_addr_t dma_addr = (dma_addr_t)rx_swcx->buf_phy_addr; struct net_device *ndev = pdata->ndev; +#ifndef OSI_STRIPPED_LIB struct osi_pkt_err_stats *pkt_err_stat = &pdata->osi_dma->pkt_err_stats; - struct skb_shared_hwtstamps *shhwtstamp; unsigned long val; +#endif /* !OSI_STRIPPED_LIB */ + struct skb_shared_hwtstamps *shhwtstamp; #ifndef ETHER_PAGE_POOL dma_unmap_single(pdata->dev, dma_addr, dma_buf_len, DMA_FROM_DEVICE); #endif + /* Check for reserve buffer */ + if (osi_unlikely(rx_swcx->buf_virt_addr == + pdata->resv_buf_virt_addr)) { + rx_swcx->buf_virt_addr = OSI_NULL; + rx_swcx->buf_phy_addr = 0; + rx_swcx->flags |= OSI_RX_SWCX_PROCESSED; + ether_realloc_rx_skb(pdata, rx_ring, chan); + return; + } + /* Process only the Valid packets */ if (likely((rx_pkt_cx->flags & OSI_PKT_CX_VALID) == OSI_PKT_CX_VALID)) { @@ -658,6 +674,7 @@ static void osd_receive_packet(void *priv, struct osi_rx_ring *rx_ring, skb->ip_summed = CHECKSUM_NONE; } +#ifndef OSI_STRIPPED_LIB if ((rx_pkt_cx->flags & OSI_PKT_CX_RSS) == OSI_PKT_CX_RSS) { skb_set_hash(skb, rx_pkt_cx->rx_hash, rx_pkt_cx->rx_hash_type); @@ -670,6 +687,7 @@ static void osd_receive_packet(void *priv, struct osi_rx_ring *rx_ring, __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), rx_pkt_cx->vlan_tag); } +#endif /* !OSI_STRIPPED_LIB */ /* Handle time stamp */ if ((rx_pkt_cx->flags & OSI_PKT_CX_PTP) == OSI_PKT_CX_PTP) { @@ -694,8 +712,10 @@ static void osd_receive_packet(void *priv, struct osi_rx_ring *rx_ring, netif_receive_skb(skb); } } else { +#ifndef OSI_STRIPPED_LIB ndev->stats.rx_crc_errors = pkt_err_stat->rx_crc_error; ndev->stats.rx_frame_errors = pkt_err_stat->rx_frame_error; +#endif /* !OSI_STRIPPED_LIB */ ndev->stats.rx_fifo_errors = osi_core->mmc.mmc_rx_fifo_overflow; ndev->stats.rx_errors++; #ifdef ETHER_PAGE_POOL diff --git a/drivers/net/ethernet/nvidia/nvethernet/ptp.c b/drivers/net/ethernet/nvidia/nvethernet/ptp.c index 667d2aa1..70bb81ec 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ptp.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ptp.c @@ -336,6 +336,7 @@ void ether_ptp_remove(struct ether_priv_data *pdata) } } +#ifndef OSI_STRIPPED_LIB /** * @brief Configure Slot function * @@ -387,6 +388,7 @@ static void ether_config_slot_function(struct ether_priv_data *pdata, u32 set) /* Call OSI slot function to configure */ osi_config_slot_function(osi_dma, set); } +#endif /* !OSI_STRIPPED_LIB */ int ether_handle_hwtstamp_ioctl(struct ether_priv_data *pdata, struct ifreq *ifr) @@ -451,15 +453,21 @@ int ether_handle_hwtstamp_ioctl(struct ether_priv_data *pdata, /* PTP v1, UDP, Sync packet */ case HWTSTAMP_FILTER_PTP_V1_L4_SYNC: - osi_core->ptp_config.ptp_filter = OSI_MAC_TCR_TSEVENTENA | + osi_core->ptp_config.ptp_filter = +#ifndef OSI_STRIPPED_LIB + OSI_MAC_TCR_TSEVENTENA | +#endif /* !OSI_STRIPPED_LIB */ OSI_MAC_TCR_TSIPV4ENA | OSI_MAC_TCR_TSIPV6ENA; break; /* PTP v1, UDP, Delay_req packet */ case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ: - osi_core->ptp_config.ptp_filter = OSI_MAC_TCR_TSMASTERENA | + osi_core->ptp_config.ptp_filter = +#ifndef OSI_STRIPPED_LIB + OSI_MAC_TCR_TSMASTERENA | OSI_MAC_TCR_TSEVENTENA | +#endif /* !OSI_STRIPPED_LIB */ OSI_MAC_TCR_TSIPV4ENA | OSI_MAC_TCR_TSIPV6ENA; break; @@ -474,7 +482,10 @@ int ether_handle_hwtstamp_ioctl(struct ether_priv_data *pdata, /* PTP v2, UDP, Sync packet */ case HWTSTAMP_FILTER_PTP_V2_L4_SYNC: - osi_core->ptp_config.ptp_filter = OSI_MAC_TCR_TSEVENTENA | + osi_core->ptp_config.ptp_filter = +#ifndef OSI_STRIPPED_LIB + OSI_MAC_TCR_TSEVENTENA | +#endif /* !OSI_STRIPPED_LIB */ OSI_MAC_TCR_TSIPV4ENA | OSI_MAC_TCR_TSIPV6ENA | OSI_MAC_TCR_TSVER2ENA; @@ -482,8 +493,11 @@ int ether_handle_hwtstamp_ioctl(struct ether_priv_data *pdata, /* PTP v2, UDP, Delay_req packet */ case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ: - osi_core->ptp_config.ptp_filter = OSI_MAC_TCR_TSEVENTENA | + osi_core->ptp_config.ptp_filter = +#ifndef OSI_STRIPPED_LIB + OSI_MAC_TCR_TSEVENTENA | OSI_MAC_TCR_TSMASTERENA | +#endif /* !OSI_STRIPPED_LIB */ OSI_MAC_TCR_TSIPV4ENA | OSI_MAC_TCR_TSIPV6ENA | OSI_MAC_TCR_TSVER2ENA; @@ -498,6 +512,7 @@ int ether_handle_hwtstamp_ioctl(struct ether_priv_data *pdata, if ((osi_dma->ptp_flag & OSI_PTP_SYNC_ONESTEP) == OSI_PTP_SYNC_ONESTEP) { +#ifndef OSI_STRIPPED_LIB osi_core->ptp_config.ptp_filter |= (OSI_MAC_TCR_TSEVENTENA | OSI_MAC_TCR_CSC); @@ -506,6 +521,7 @@ int ether_handle_hwtstamp_ioctl(struct ether_priv_data *pdata, osi_core->ptp_config.ptp_filter |= OSI_MAC_TCR_TSMASTERENA; } +#endif /* !OSI_STRIPPED_LIB */ } else { osi_core->ptp_config.ptp_filter |= OSI_MAC_TCR_SNAPTYPSEL_1; @@ -517,9 +533,11 @@ int ether_handle_hwtstamp_ioctl(struct ether_priv_data *pdata, osi_core->ptp_config.ptp_filter = OSI_MAC_TCR_TSIPV4ENA | OSI_MAC_TCR_TSIPV6ENA | OSI_MAC_TCR_TSVER2ENA | +#ifndef OSI_STRIPPED_LIB OSI_MAC_TCR_TSEVENTENA | - OSI_MAC_TCR_TSIPENA | - OSI_MAC_TCR_AV8021ASMEN; + OSI_MAC_TCR_AV8021ASMEN | +#endif /* !OSI_STRIPPED_LIB */ + OSI_MAC_TCR_TSIPENA; break; /* PTP v2/802.AS1, any layer, Delay_req packet */ @@ -527,16 +545,20 @@ int ether_handle_hwtstamp_ioctl(struct ether_priv_data *pdata, osi_core->ptp_config.ptp_filter = OSI_MAC_TCR_TSIPV4ENA | OSI_MAC_TCR_TSIPV6ENA | OSI_MAC_TCR_TSVER2ENA | +#ifndef OSI_STRIPPED_LIB OSI_MAC_TCR_TSEVENTENA | OSI_MAC_TCR_AV8021ASMEN | OSI_MAC_TCR_TSMASTERENA | +#endif /* !OSI_STRIPPED_LIB */ OSI_MAC_TCR_TSIPENA; break; +#ifndef OSI_STRIPPED_LIB /* time stamp any incoming packet */ case HWTSTAMP_FILTER_ALL: osi_core->ptp_config.ptp_filter = OSI_MAC_TCR_TSENALL; break; +#endif /* !OSI_STRIPPED_LIB */ default: dev_err(pdata->dev, "rx_filter is out of range\n"); @@ -552,7 +574,9 @@ int ether_handle_hwtstamp_ioctl(struct ether_priv_data *pdata, dev_err(pdata->dev, "Failure to disable CONFIG_PTP\n"); return -EFAULT; } +#ifndef OSI_STRIPPED_LIB ether_config_slot_function(pdata, OSI_DISABLE); +#endif /* !OSI_STRIPPED_LIB */ } else { /* Store default PTP clock frequency, so that we * can make use of it for coarse correction */ @@ -574,7 +598,9 @@ int ether_handle_hwtstamp_ioctl(struct ether_priv_data *pdata, } /* Register broadcasting MAC timestamp to clients */ tegra_register_hwtime_source(ether_get_hw_time, ndev); +#ifndef OSI_STRIPPED_LIB ether_config_slot_function(pdata, OSI_ENABLE); +#endif /* !OSI_STRIPPED_LIB */ } return (copy_to_user(ifr->ifr_data, &config, diff --git a/drivers/net/ethernet/nvidia/nvethernet/selftests.c b/drivers/net/ethernet/nvidia/nvethernet/selftests.c index a5ec0cad..ae162a16 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/selftests.c +++ b/drivers/net/ethernet/nvidia/nvethernet/selftests.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved */ +#ifndef OSI_STRIPPED_LIB #include "ether_linux.h" #include @@ -481,3 +482,4 @@ int ether_selftest_get_count(struct ether_priv_data *pdata) { return ARRAY_SIZE(ether_selftests); } +#endif /* OSI_STRIPPED_LIB */ diff --git a/drivers/net/ethernet/nvidia/nvethernet/sysfs.c b/drivers/net/ethernet/nvidia/nvethernet/sysfs.c index 41bcb1e8..825fefee 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/sysfs.c +++ b/drivers/net/ethernet/nvidia/nvethernet/sysfs.c @@ -8,6 +8,7 @@ #include #endif +#ifndef OSI_STRIPPED_LIB #ifdef CONFIG_DEBUG_FS /* As per IAS Docs */ #define EOQS_MAX_REGISTER_ADDRESS 0x12FC @@ -451,137 +452,6 @@ static DEVICE_ATTR(macsec_loopback, (S_IRUGO | S_IWUSR), macsec_loopback_store); #endif /* DEBUG_MACSEC */ -#ifdef HSI_SUPPORT -#if (IS_ENABLED(CONFIG_TEGRA_HSIERRRPTINJ)) -static int hsi_inject_err_fsi(unsigned int inst_id, - struct epl_error_report_frame error_report, - void *data) -{ - struct ether_priv_data *pdata = (struct ether_priv_data *)data; - struct osi_core_priv_data *osi_core = pdata->osi_core; - struct osi_ioctl ioctl_data = {}; - int ret; - - ioctl_data.cmd = OSI_CMD_HSI_INJECT_ERR; - ioctl_data.arg1_u32 = error_report.error_code; - ret = osi_handle_ioctl(osi_core, &ioctl_data); - if (ret < 0) - dev_err(pdata->dev, "Fail to inject error\n"); - - return ret; -} -#endif - -/** - * @brief Shows HSI feature enabled status - * - * Algorithm: Shows HSI feature enabled status - * - * @param[in] dev: Device data. - * @param[in] attr: Device attribute - * @param[in] buf: Buffer to store the current status - */ -static ssize_t hsi_enable_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct net_device *ndev = (struct net_device *)dev_get_drvdata(dev); - struct ether_priv_data *pdata = netdev_priv(ndev); - struct osi_core_priv_data *osi_core = pdata->osi_core; - - return scnprintf(buf, PAGE_SIZE, "%s\n", - (osi_core->hsi.enabled == OSI_ENABLE) ? - "enabled" : "disabled"); -} - -/** - * @brief Set HSI enabled status - * - * Algorithm: This is used to set HSI feature enable status - * - * @param[in] dev: Device data. - * @param[in] attr: Device attribute - * @param[in] buf: Buffer which contains the user input - * @param[in] size: size of buffer - * - * @return size of buffer. - */ -static ssize_t hsi_enable_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t size) -{ - struct net_device *ndev = (struct net_device *)dev_get_drvdata(dev); - struct ether_priv_data *pdata = netdev_priv(ndev); - struct osi_core_priv_data *osi_core = pdata->osi_core; - struct osi_ioctl ioctl_data = {}; - int ret = 0; -#if (IS_ENABLED(CONFIG_TEGRA_HSIERRRPTINJ)) - u32 inst_id = osi_core->instance_id; - u32 ip_type[2] = {IP_EQOS, IP_MGBE}; -#endif - if (!netif_running(ndev)) { - dev_err(pdata->dev, "Not Allowed. Ether interface is not up\n"); - return size; - } - - ioctl_data.cmd = OSI_CMD_HSI_CONFIGURE; - if (strncmp(buf, "enable", 6) == OSI_NONE) { - ioctl_data.arg1_u32 = OSI_ENABLE; - ret = osi_handle_ioctl(pdata->osi_core, &ioctl_data); - if (ret < 0) { - dev_err(pdata->dev, - "Failed to enable HSI\n"); - } else { - osi_core->hsi.enabled = OSI_ENABLE; - dev_info(pdata->dev, "HSI Enabled\n"); -#if (IS_ENABLED(CONFIG_TEGRA_HSIERRRPTINJ)) - if (osi_core->instance_id == OSI_INSTANCE_ID_EQOS) - inst_id = 0; - - ret = hsierrrpt_reg_cb(ip_type[osi_core->mac], inst_id, - hsi_inject_err_fsi, pdata); - if (ret != 0) { - dev_err(pdata->dev, "Err inj callback registration failed: %d", - ret); - } -#endif - } - } else if (strncmp(buf, "disable", 7) == OSI_NONE) { - ioctl_data.arg1_u32 = OSI_DISABLE; - ret = osi_handle_ioctl(pdata->osi_core, &ioctl_data); - if (ret < 0) { - dev_err(pdata->dev, - "Failed to disable HSI\n"); - } else { - osi_core->hsi.enabled = OSI_DISABLE; - dev_info(pdata->dev, "HSI Disabled\n"); -#if (IS_ENABLED(CONFIG_TEGRA_HSIERRRPTINJ)) - if (osi_core->instance_id == OSI_INSTANCE_ID_EQOS) - inst_id = 0; - - ret = hsierrrpt_dereg_cb(ip_type[osi_core->mac], inst_id); - if (ret != 0) { - dev_err(pdata->dev, "Err inj callback deregistration failed: %d", - ret); - } -#endif - } - } else { - dev_err(pdata->dev, - "Invalid entry. Valid Entries are enable/disable\n"); - } - - return size; -} - -/** - * @brief Sysfs attribute for HSI enable - * - */ -static DEVICE_ATTR(hsi_enable, 0644, - hsi_enable_show, - hsi_enable_store); -#endif - #define MAC_ADDR_FMT "%02x:%02x:%02x:%02x:%02x:%02x" #define ETHTYPE_FMT "%02x%02x" #define SCI_FMT "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x" @@ -2676,11 +2546,144 @@ static ssize_t ether_nvgro_dump_show(struct device *dev, static DEVICE_ATTR(nvgro_dump, 0644, ether_nvgro_dump_show, NULL); #endif +#endif /* OSI_STRIPPED_LIB */ + +#ifdef HSI_SUPPORT +#if (IS_ENABLED(CONFIG_TEGRA_HSIERRRPTINJ)) +static int hsi_inject_err_fsi(unsigned int inst_id, + struct epl_error_report_frame error_report, + void *data) +{ + struct ether_priv_data *pdata = (struct ether_priv_data *)data; + struct osi_core_priv_data *osi_core = pdata->osi_core; + struct osi_ioctl ioctl_data = {}; + int ret; + + ioctl_data.cmd = OSI_CMD_HSI_INJECT_ERR; + ioctl_data.arg1_u32 = error_report.error_code; + ret = osi_handle_ioctl(osi_core, &ioctl_data); + if (ret < 0) + dev_err(pdata->dev, "Fail to inject error\n"); + + return ret; +} +#endif + +/** + * @brief Shows HSI feature enabled status + * + * Algorithm: Shows HSI feature enabled status + * + * @param[in] dev: Device data. + * @param[in] attr: Device attribute + * @param[in] buf: Buffer to store the current status + */ +static ssize_t hsi_enable_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct net_device *ndev = (struct net_device *)dev_get_drvdata(dev); + struct ether_priv_data *pdata = netdev_priv(ndev); + struct osi_core_priv_data *osi_core = pdata->osi_core; + + return scnprintf(buf, PAGE_SIZE, "%s\n", + (osi_core->hsi.enabled == OSI_ENABLE) ? + "enabled" : "disabled"); +} + +/** + * @brief Set HSI enabled status + * + * Algorithm: This is used to set HSI feature enable status + * + * @param[in] dev: Device data. + * @param[in] attr: Device attribute + * @param[in] buf: Buffer which contains the user input + * @param[in] size: size of buffer + * + * @return size of buffer. + */ +static ssize_t hsi_enable_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t size) +{ + struct net_device *ndev = (struct net_device *)dev_get_drvdata(dev); + struct ether_priv_data *pdata = netdev_priv(ndev); + struct osi_core_priv_data *osi_core = pdata->osi_core; + struct osi_ioctl ioctl_data = {}; + int ret = 0; +#if (IS_ENABLED(CONFIG_TEGRA_HSIERRRPTINJ)) + u32 inst_id = osi_core->instance_id; + u32 ip_type[2] = {IP_EQOS, IP_MGBE}; +#endif + if (!netif_running(ndev)) { + dev_err(pdata->dev, "Not Allowed. Ether interface is not up\n"); + return size; + } + + ioctl_data.cmd = OSI_CMD_HSI_CONFIGURE; + if (strncmp(buf, "enable", 6) == OSI_NONE) { + ioctl_data.arg1_u32 = OSI_ENABLE; + ret = osi_handle_ioctl(pdata->osi_core, &ioctl_data); + if (ret < 0) { + dev_err(pdata->dev, + "Failed to enable HSI\n"); + } else { + osi_core->hsi.enabled = OSI_ENABLE; + dev_info(pdata->dev, "HSI Enabled\n"); +#if (IS_ENABLED(CONFIG_TEGRA_HSIERRRPTINJ)) + if (osi_core->instance_id == OSI_INSTANCE_ID_EQOS) + inst_id = 0; + + ret = hsierrrpt_reg_cb(ip_type[osi_core->mac], inst_id, + hsi_inject_err_fsi, pdata); + if (ret != 0) { + dev_err(pdata->dev, "Err inj callback registration failed: %d", + ret); + } +#endif + } + } else if (strncmp(buf, "disable", 7) == OSI_NONE) { + ioctl_data.arg1_u32 = OSI_DISABLE; + ret = osi_handle_ioctl(pdata->osi_core, &ioctl_data); + if (ret < 0) { + dev_err(pdata->dev, + "Failed to disable HSI\n"); + } else { + osi_core->hsi.enabled = OSI_DISABLE; + dev_info(pdata->dev, "HSI Disabled\n"); +#if (IS_ENABLED(CONFIG_TEGRA_HSIERRRPTINJ)) + if (osi_core->instance_id == OSI_INSTANCE_ID_EQOS) + inst_id = 0; + + ret = hsierrrpt_dereg_cb(ip_type[osi_core->mac], inst_id); + if (ret != 0) { + dev_err(pdata->dev, "Err inj callback deregistration failed: %d", + ret); + } +#endif + } + } else { + dev_err(pdata->dev, + "Invalid entry. Valid Entries are enable/disable\n"); + } + + return size; +} + +/** + * @brief Sysfs attribute for HSI enable + * + */ +static DEVICE_ATTR(hsi_enable, 0644, + hsi_enable_show, + hsi_enable_store); +#endif /** * @brief Attributes for nvethernet sysfs */ static struct attribute *ether_sysfs_attrs[] = { +#ifndef OSI_STRIPPED_LIB #ifdef OSI_DEBUG &dev_attr_desc_dump_enable.attr, #endif /* OSI_DEBUG */ @@ -2718,6 +2721,7 @@ static struct attribute *ether_sysfs_attrs[] = { &dev_attr_nvgro_stats.attr, &dev_attr_nvgro_dump.attr, #endif +#endif /* OSI_STRIPPED_LIB */ #ifdef HSI_SUPPORT &dev_attr_hsi_enable.attr, #endif @@ -2732,6 +2736,7 @@ static struct attribute_group ether_attribute_group = { .attrs = ether_sysfs_attrs, }; +#ifndef OSI_STRIPPED_LIB #ifdef CONFIG_DEBUG_FS static char *timestamp_system_source(unsigned int source) { @@ -3301,12 +3306,14 @@ static void ether_remove_debugfs(struct ether_priv_data *pdata) debugfs_remove_recursive(pdata->dbgfs_dir); } #endif /* CONFIG_DEBUG_FS */ +#endif /* OSI_STRIPPED_LIB */ int ether_sysfs_register(struct ether_priv_data *pdata) { struct device *dev = pdata->dev; int ret = 0; +#ifndef OSI_STRIPPED_LIB #ifdef CONFIG_DEBUG_FS if (debugfs_initialized()) { ret = ether_create_debugfs(pdata); @@ -3314,6 +3321,7 @@ int ether_sysfs_register(struct ether_priv_data *pdata) return ret; } #endif +#endif /* OSI_STRIPPED_LIB */ /* Create nvethernet sysfs group under /sys/devices// */ return sysfs_create_group(&dev->kobj, ðer_attribute_group); @@ -3322,9 +3330,11 @@ int ether_sysfs_register(struct ether_priv_data *pdata) void ether_sysfs_unregister(struct ether_priv_data *pdata) { struct device *dev = pdata->dev; +#ifndef OSI_STRIPPED_LIB #ifdef CONFIG_DEBUG_FS ether_remove_debugfs(pdata); #endif +#endif /* OSI_STRIPPED_LIB */ /* Remove nvethernet sysfs group under /sys/devices// */ sysfs_remove_group(&dev->kobj, ðer_attribute_group); }