diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_callback_export.h b/drivers/net/ethernet/nvidia/nvethernet/ether_callback_export.h new file mode 100644 index 00000000..f009d353 --- /dev/null +++ b/drivers/net/ethernet/nvidia/nvethernet/ether_callback_export.h @@ -0,0 +1,2006 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved */ + +#ifndef ETHER_CALLBACK_EXPORT_H +#define ETHER_CALLBACK_EXPORT_H + +#ifdef DOXYGEN +#define __user +#endif /* DOXYGEN */ + +/** + * @brief + * Description: + * - Ethernet platform driver probe. + * + * @param[in] pdev: + * - Platform device associated with platform driver. + * - Used Structure variables: pdev->dev, pdev->dev.of_node + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: Yes + * - Run time: No + * - De-initialization: No + * + * @return + * - EOK on success + * - "-ENOMEM" on memory allocation failure for private data structures. + * - "-EINVAL" on invalid input data values. + * - "-ENOMEM" on NVETHERNETRM_PIF#osi_get_core fail. + * - "-ENOMEM" on NVETHERNETRM_PIF#osi_get_dma fail. + * - Return values of NVETHERNETRM_PIF#osi_handle_ioctl with + * the NVETHERNETRM_PIF$OSI_CMD_GET_HW_FEAT command. + * - Return vlaues of register_netdev() on Net device regitration fail. + * - Return vlaues of sysfs_create_group() on sysfs group create fail. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Get the number of channels from DT. + * - Allocate the network device for those many channels. + * - Parse MAC and PHY DT. + * - Get all required clks/reset/IRQ's. + * - Register MDIO bus and network device. + * - Initialize spinlock. + * - Update filter value based on HW feature. + * - Update osi_core->hw_feature with pdata->hw_feat pointer + * - Initialize Workqueue to read MMC counters periodically. + * + */ +#endif /* DOXYGEN_ICD */ +int ether_probe(struct platform_device *pdev); + +/** + * @brief + * Description: + * - Ethernet platform driver remove. + * + * @param[in] pdev: + * - Platform device associated with platform driver. + * - The ``pdev`` structure variable is used to retrieve pointers to struct net_device and the private data structure. + * - Used Structure variables: pdev->dev.of_node + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: No + * - De-initialization: Yes + * + * @pre Ethernet driver probe NVETHERNET_LINUX_PIF#ether_probe event + * need to be completed successfully. + * + * @return + * - EOK on after clean-up. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Alogorithm: + * - Release all the resources + * + */ +#endif /* DOXYGEN_ICD */ +int ether_remove(struct platform_device *pdev); + +/** + * @brief + * Description: + * - Ethernet platform driver shutdown. + * + * @param[in] pdev: + * - Platform device associated with platform driver. + * - The pdev structure variable is used to retrieve pointers to struct net_device and the private data structure. + * - Used Structure variables: None + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: No + * - De-initialization: Yes + * + * @pre Ethernet driver probe NVETHERNET_LINUX_PIF#ether_probe event + * need to be completed successfully with ethernet network device created. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Alogorithm: + * - Stops and Deinits PHY, MAC, DMA and Clks hardware + * - Release SW allocated resources(buffers, workqueues etc) + * + */ +#endif /* DOXYGEN_ICD */ +void ether_shutdown(struct platform_device *pdev); + +/** + * @brief + * Description: + * - Ethernet platform driver suspend noirq callback. + * + * @param[in] dev: + * - Platform device associated with platform driver. + * - The ``dev`` structure variable is used to retrieve pointers to struct net_device and the private data structure. + * - Used Structure variables: None + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: No + * - De-initialization: Yes + * + * @pre Ethernet driver probe NVETHERNET_LINUX_PIF#ether_probe event + * need to be completed successfully with ethernet network device created. + * + * @return + * - EOK on success + * - "-EBUSY" on NVETHERNETRM_PIF#osi_handle_ioctl with NVETHERNETRM_PIF$OSI_CMD_SUSPEND fail. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Alogorithm: + * - Stops all data queues and PHY if the device + * does not wake capable. + * - Disable TX and NAPI. + * - Deinit OSI core, DMA and TX/RX interrupts. + * + */ +#endif /* DOXYGEN_ICD */ +int ether_suspend_noirq(struct device *dev); + +/** + * @brief + * Description: + * - Ethernet platform driver resume noirq callback. + * + * @param[in] dev: + * - Net device data structure. + * - The ``dev`` structure variable is used to retrieve pointers to struct net_device and the private data structure. + * - Used Structure variables: None + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: Yes + * - Run time: No + * - De-initialization: No + * + * @pre Ethernet driver probe NVETHERNET_LINUX_PIF#ether_probe event + * need to be completed successfully with ethernet network device created. + * + * @return + * - EOK on success + * - Return values of NVETHERNETRM_PIF#osi_handle_ioctl, + * with the NVETHERNETRM_PIF$OSI_CMD_RESUME command data. + * - Return values of NVETHERNETRM_PIF#osi_handle_ioctl, + * with the NVETHERNETRM_PIF$OSI_CMD_PAD_CALIBRATION command data. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Alogorithm: + * - Enable clocks and perform resume sequence + * + */ +#endif /* DOXYGEN_ICD */ +int ether_resume_noirq(struct device *dev); + +/** + * @brief + * Description: + * - Call back to handle bring up of Ethernet interface + * + * @param[in] dev: + * - Net device data structure. + * - The ``dev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: Yes + * - Run time: No + * - De-initialization: No + * + * @pre Ethernet driver probe NVETHERNET_LINUX_PIF#ether_probe event + * need to be completed successfully with ethernet network device created. + * + * @return + * - EOK on success + * - "-EINVAL" on invalid input data values. + * - Return values of NVETHERNETRM_PIF#osi_hw_core_init value. + * - Return values of NVETHERNETRM_PIF#osi_handle_ioctl, + * with the NVETHERNETRM_PIF$OSI_CMD_L2_FILTER command data. + * - Return values of NVETHERNETRM_PIF#osi_hw_core_init. + * - Return values of NVETHERNETRM_PIF#osi_hw_dma_init. + * - Return values of NVETHERNETRM_PIF#osi_handle_ioctl, + * with the NVETHERNETRM_PIF$OSI_CMD_FREE_TS command data. + * - Return values of NVETHERNETRM_PIF#osi_handle_ioctl, + * with the NVETHERNETRM_PIF$OSI_CMD_PAD_CALIBRATION command data. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: This routine takes care of below + * - PHY initialization + * - request tx/rx/common irqs + * - HW initialization + * - OSD private data structure initialization + * - Starting the PHY + * + */ +#endif /* DOXYGEN_ICD */ +int ether_open(struct net_device *dev); + +/** + * @brief + * Description: + * - Call back to handle bring down of Ethernet interface + * + * @param[in] ndev: + * - Net device structure. + * - The ``ndev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: No + * - De-initialization: Yes + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @return + * - EOK on success + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: This routine takes care of below + * - Stopping PHY + * - Freeing tx/rx/common irqs + * + */ +#endif /* DOXYGEN_ICD */ +int ether_close(struct net_device *ndev); + +/** + * @brief + * Description: + * - Network layer hook for data transmission. + * + * @param[in] skb: + * - SKB data structure. + * - Used Structure variables: skb->len, skb->gso_type, + * skb->gso_size, skb->ip_summed, skb->tx_flags, skb->data + * @param[in] ndev: + * - Net device structure. + * - The ``ndev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @return + * - NETDEV_TX_OK on successful packet queue insertion. + * - NETDEV_TX_BUSY if the queue is full. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Allocate software context (DMA address for the buffer) for the data. + * - Invoke OSI for data transmission. + * + */ +#endif /* DOXYGEN_ICD */ +int ether_start_xmit(struct sk_buff *skb, struct net_device *ndev); + +/** + * @brief + * Description: + * - VM based ISR routine for receive done. + * + * @param[in] irq: + * - IRQ number + * @param[in] data: + * - VM IRQ data private data structure. + * + * @usage + * - Allowed context for the API call + * - Interrupt: Yes + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @return + * - IRQ_HANDLED on success handling of the TX Done. + * - IRQ_HANDLED on success handling of the RX packet. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Get global DMA status (common for all VM IRQ's) + * + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + * + RX7 + TX7 + RX6 + TX6 + . . . . . . . + RX1 + TX1 + RX0 + TX0 + + * + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + * + * - Mask the channels which are specific to VM in global DMA status. + * - Process all DMA channel interrupts which are triggered the IRQ + * a) Find first first set from LSB with ffs + * b) The least significant bit is position 1 for ffs. So decremented + * by one to start from zero. + * c) Get channel number and TX/RX info by using bit position. + * d) Invoke OSI layer to clear interrupt source for DMA Tx/Rx at + * DMA and wrapper level. + * e) Get NAPI instance based on channel number and schedule the same. + * + */ +#endif /* DOXYGEN_ICD */ +irqreturn_t ether_vm_isr(int irq, void *data); + +/** + * @brief + * Description: + * - Network stack ndo_eth_ioctl callback hook to driver. + * + * @param[in] dev: + * - network device structure + * - The ``dev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * @param[inout] rq: + * - Interface request structure used for device. + * - The ``rd`` structure variable is used to retrieve pointers + * to the mii_ioctl_data data structure and hwtstamp_config structure. + * - Used Structure variables: + * - For SIOCGMIIPHY: mii_ioctl_data->phy_id, mii_ioctl_data->reg_num + * - For SIOCGMIIREG: mii_ioctl_data->phy_id, mii_ioctl_data->reg_num + * - For SIOCSMIIREG:: mii_ioctl_data->phy_id, mii_ioctl_data->reg_num + * - For SIOCSHWTSTAMP: hwtstamp_config->flags, hwtstamp_config->tx_type, + * hwtstamp_config->rx_filter + * @param[in] cmd: + * - Net device IOCTL command. + * - SIOCGMIIPHY: read register from the current PHY. + * - SIOCGMIIREG: read register from the specified PHY. + * - SIOCSMIIREG: set a register on the specified PHY. + * - SIOCSHWTSTAMP: Configure hardware time stamping. + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @return + * - EOK on success + * - "-EINVAL" on invalid input data values. + * - "-EINVAL" on invalid PHY register read/write operatinos. + * - Return values of NVETHERNETRM_PIF#osi_read_phy_reg for SIOCGMIIREG cmd value. + * - Return values of NVETHERNETRM_PIF#osi_read_phy_reg for SIOCSMIIREG cmd value. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Invokes MII API for phy read/write based on IOCTL command + * + */ +#endif /* DOXYGEN_ICD */ +int ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); + +/** + * @brief + * Description: + * - Network stack ndo_siocdevprivate callback hook to driver. + * + * @param[in] dev: + * - network device structure + * - The ``dev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * @param[inout] rq: + * - Interface request structure used for device. + * - The ``rd`` structure variable is used to retrieve pointers + * to the private ioctl ether_exported_ifr_data structure. + * - Used Structure variables: + * - For all supported private IOCTLs Refer NVETHERNET_LINUX_PIF$ether_exported_ifr_data + * @param[in] data: Not used + * - Pointer to the user data for the IOCTL. + * @param[in] cmd: + * - Net device IOCTL command, valid values: + * - SIOCDEVPRIVATE: For Net device private IOCTLs + * - NVETHERNET_LINUX_PIF$ETHER_PRV_TS_IOCTL + * - NVETHERNET_LINUX_PIF$ETHER_PRV_RMDIO_IOCTL + * - NVETHERNET_LINUX_PIF$ETHER_PRV_WMDIO_IOCTL + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @return + * - EOK on success + * - "-EINVAL" on invalid input data values. + * - "-EINVAL" if called before NVETHERNET_LINUX_PIF#ether_open event success. + * - "-EOPNOTSUPP" on unsupported valued in cmd or rd + * - "-EFAULT" on user IOCTL data copy + * - "-EPERM" on user non admin user call + * - Return values of NVETHERNETRM_PIF#osi_handle_ioctl for the cmd value SIOCDEVPRIVATE, + * with the NVETHERNET_LINUX_PIF$ether_exported_ifr_data.ifcmd in the "rd" input parameter. + * - Return values of NVETHERNETRM_PIF#osi_read_phy_reg for the cmd value ETHER_PRV_RMDIO_IOCTL. + * - Return values of NVETHERNETRM_PIF#osi_write_phy_reg for the cmd value ETHER_PRV_WMDIO_IOCTL. + * - Return values of NVETHERNETRM_PIF#osi_dma_get_systime_from_mac for the cmd value ETHER_PRV_TS_IOCTL. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Handle below Linux NDO private IOCTL's + * + */ +#endif /* DOXYGEN_ICD */ +int ether_siocdevprivate(struct net_device *dev, struct ifreq *rq, + void __user *data, int cmd); +/** + * @brief + * Description: + * - TC HW offload support + * + * @param[in] ndev: + * - Network device structure + * - The ``ndev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * @param[in] type: + * - qdisc type supported values: + * - TC_SETUP_QDISC_TAPRIO + * - TC_SETUP_QDISC_CBS + * @param[in] type_data: + * - void pointer having user passed configuration struct tc_taprio_qopt_offload + * - Used Structure variables: tc_taprio_qopt_offload->num_entries, + * tc_taprio_qopt_offload->base_time, tc_taprio_qopt_offload->cycle_time + * tc_taprio_qopt_offload->enable, tc_taprio_qopt_offload->cmd + * tc_taprio_qopt_offload->entries[i].interval, + * tc_taprio_qopt_offload->entries[i].command + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @return + * - EOK on success + * - "-ERANGE" invalid number of GCL entries. + * - "-ERANGE" invalid base time. + * - "-ERANGE" invalid cycle time. + * - "-EINVAL" invalid input argument. + * - "-EOPNOTSUPP" Not supported TC set-up types and commands. + * - Return values of NVETHERNETRM_PIF#osi_handle_ioctl with + * the NVETHERNETRM_PIF$OSI_CMD_SET_AVB command. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Check the TC setup type + * - Call appropriate function based on type. + * + */ +#endif /* DOXYGEN_ICD */ +int ether_setup_tc(struct net_device *ndev, enum tc_setup_type type, + void *type_data); + +/** + * @brief + * Description: + * - Change MAC MTU size + * + * @param[in] ndev: + * - Network device structure + * - The ``ndev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * @param[in] new_mtu: + * - New MTU size to set. + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre Ethernet interface need to be down with NVETHERNET_LINUX_PIF#ether_close event + * + * @return + * - EOK on success + * - "-EINVAL" If the new_mtu is more than NVETHERNETRM_PIF$OSI_MTU_SIZE_9000 + * - Return values of NVETHERNETRM_PIF#osi_handle_ioctl with + * the NVETHERNETRM_PIF$OSI_CMD_MAC_MTU command. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Check and return if interface is up. + * - Stores new MTU size set by user in OSI core data structure. + */ +#endif /* DOXYGEN_ICD */ +int ether_change_mtu(struct net_device *ndev, int new_mtu); + +/** + * @brief + * Description: + * - Change HW features for the given network device. + * + * @param[in] ndev: + * - Network device structure + * - The ``ndev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * @param[in] feat: + * - Net device HW features flags type of u64. + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @return + * - EOK on RX checksum enable/diable success. + * - Return values of NVETHERNETRM_PIF#osi_handle_ioctl with + * the NVETHERNETRM_PIF$OSI_CMD_RXCSUM_OFFLOAD command. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Check if HW supports feature requested to be changed + * - If supported, check the current status of the feature and if it + * needs to be toggled, do so. + */ +#endif /* DOXYGEN_ICD */ +int ether_set_features(struct net_device *ndev, netdev_features_t feat); + +/** + * @brief + * Description: + * - This function is used to set RX mode. + * + * @param[in] dev + * - pointer to net_device structure. + * - The ``dev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre MAC and PHY need to be initialized, by invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: Based on Network interface flag, MAC registers are programmed to + * set mode. + */ +#endif /* DOXYGEN_ICD */ +void ether_set_rx_mode(struct net_device *dev); + +/** + * @brief + * Description: + * - Select queue based on user priority + * + * @param[in] dev: + * - Network device pointer + * - The ``dev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * @param[in] skb: + * - sk_buff pointer, buffer data to send + * - Used Structure variables: skb->priority + * @param[in] sb_dev: + * - sk_buff Network device pointer + * - Used Structure variables: None + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @return + * - Transmit queue index on successful + * execution of the select queue operation. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Select the correct queue index based which has priority of queue + * same as skb->priority + * - default select queue array index 0 + * + */ +#endif /* DOXYGEN_ICD */ +unsigned short ether_select_queue(struct net_device *dev, + struct sk_buff *skb, + struct net_device *sb_dev); + +/** + * @brief + * Description: + * - This function returns a set of strings that describe + * the requested objects. + * + * @param[in] dev: + * - Pointer to net device structure. + * - The ``dev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * @param[in] stringset: + * - String set value. + * @param[in] data: + * - Pointer in which requested string should be put. + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - return number of strings. + * + */ +#endif /* DOXYGEN_ICD */ +void ether_get_strings(struct net_device *dev, u32 stringset, u8 *data); + +/** + * @brief + * Description: + * - Adjust link call back for Linux PHY sus system. + * + * @param[in] dev: + * - Pointer to net device structure. + * - The ``dev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Callback function called by the PHY subsystem + * whenever there is a link detected or link changed on the + * physical layer. + * + */ +#endif /* DOXYGEN_ICD */ +void ether_adjust_link(struct net_device *dev); + +/** + * @brief + * Description: + * - This function is invoked by kernel when user requests to get the + * extended statistics about the device. + * + * @param[in] dev: + * - Pointer to net device structure. + * - The ``dev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * @param[in] dummy: + * - Pointer to the ethtool_stats structure type. + * - Used Structure variables: None + * @param[in] data: + * - Pointer in which MMC statistics should be put. + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Read mmc register and create strings + * + */ +#endif /* DOXYGEN_ICD */ +void ether_get_ethtool_stats(struct net_device *dev, + struct ethtool_stats *dummy, + u64 *data); + +/** + * @brief + * Description: + * - This function gets number of strings + * + * @param[in] dev: + * - Pointer to net device structure. + * - The ``dev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * @param[in] sset: + * - String set value. + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @return + * - Size stats when sset is ETH_SS_STATS. + * - Count of self test when sset is ETH_SS_TEST. + * - "-EOPNOTSUPP" if sset is other than ETH_SS_TEST or ETH_SS_STATS. + + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Return number of strings. + * + */ +#endif /* DOXYGEN_ICD */ +int ether_get_sset_count(struct net_device *dev, int sset); + +#ifndef OSI_STRIPPED_LIB +/** + * @brief + * Description: + * - This function is invoked by kernel when user request to get report + * whether wake-on-lan is enable or not. + * + * @param[in] ndev: + * - Pointer to net device structure. + * - The ``ndev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * param[in] wol + * – pointer to ethtool_wolinfo structure. + * - Used Structure variables: wol->supported, wol->wolopts. + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Return Wake On Lan status in wol param + * + */ +#endif /* DOXYGEN_ICD */ +void ether_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol); + +/** + * @brief + * Description: + * - This function is invoked by kernel when user request to set + * pmt parameters for remote wakeup or magic wakeup + * + * @param[in] ndev: + * - Pointer to net device structure. + * - The ``ndev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * param[in] wol + * – pointer to ethtool_wolinfo structure. + * - Used Structure variables: wol->wolopts. + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @return + * - EOK on success + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Enable or Disable Wake On Lan status based on wol param + * + */ +#endif /* DOXYGEN_ICD */ +int ether_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol); + +/** + * @brief + * Description: + * - Ethernet selftests. + * + * @param[in] ndev: + * - Pointer to net device structure. + * - The ``ndev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * @param[in] etest: + * - Ethernet ethtool test pointer. + * - Used Structure variables: etest->flags + * @param[in] buf: + * - Buffer pointer to hold test status. + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Enable or Disable Wake On Lan status based on wol param + * + */ +#endif /* DOXYGEN_ICD */ +void ether_selftest_run(struct net_device *dev, + struct ethtool_test *etest, u64 *buf); + +/** + * @brief + * Description: + * - Get RX flow classification rules + * + * @param[in] ndev: + * - Pointer to net device structure. + * - The ``ndev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * param[in] rxnfc: + * - Pointer to rxflow data + * - Used Structure variables: rxnfc->cmd + * param[in] rule_locs: + * - Rule location number + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @return + * - EOK on success + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Returns RX flow classification rules. + * + */ +#endif /* DOXYGEN_ICD */ +int ether_get_rxnfc(struct net_device *ndev, + struct ethtool_rxnfc *rxnfc, + u32 *rule_locs); + +/** + * @brief + * Description: + * - Get pause frame settings + * + * @param[in] ndev: + * - Pointer to net device structure. + * - The ``ndev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * @param[out] pause: + * - Pause parameters that are set currently + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @return + * - EOK on success + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Gets pause frame configuration + * + */ +#endif /* DOXYGEN_ICD */ +void ether_get_pauseparam(struct net_device *ndev, + struct ethtool_pauseparam *pause); + +/** + * @brief + * Description: + * - Set pause frame settings + * + * @param[in] ndev: + * - Pointer to net device structure. + * - The ``ndev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * @param[in] pause: + * - Pause parameters that needs to set into MAC. + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @return + * - EOK on success + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Sets pause frame settings + * + */ +#endif /* DOXYGEN_ICD */ +int ether_set_pauseparam(struct net_device *ndev, + struct ethtool_pauseparam *pause); + +/** + * @brief + * Description: + * - Get the size of the RX flow hash key + * + * @param[in] ndev: + * - Pointer to net device structure. + * - The ``ndev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @return + * - Size of RSS Hash key + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Returns size of RSS hash key + * + */ +#endif /* DOXYGEN_ICD */ +u32 ether_get_rxfh_key_size(struct net_device *ndev); + +/** + * @brief + * Description: + * - Get the size of the RX flow hash indirection table + * + * @param[in] ndev: + * - Pointer to net device structure. + * - The ``ndev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @return + * - Size of RSS Hash table + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Returns size of the RX flow hash indirection table + * + */ +#endif /* DOXYGEN_ICD */ +u32 ether_get_rxfh_indir_size(struct net_device *ndev); + +/** + * @brief + * Description: + * - Get the debug message level of the driver + * + * @param[in] ndev: + * - Pointer to net device structure. + * - The ``ndev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @return + * - message level set in the driver + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Returns the message level set in the driver. + * + */ +#endif /* DOXYGEN_ICD */ +unsigned int ether_get_msglevel(struct net_device *ndev); + +/** + * @brief + * Description: + * - Set the debug message level into the driver + * + * @param[in] ndev: + * - Pointer to net device structure. + * - The ``ndev`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * @param[in] level: + * - debug message level + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Returns the message level set in the driver. + * + */ +#endif /* DOXYGEN_ICD */ +void ether_set_msglevel(struct net_device *ndev, u32 level); +#endif /* OSI_STRIPPED_LIB */ + +/* Work Queue functions */ +/** + * @brief + * Description: + * - Work Queue function to call NVETHERNETRM_PIF#osi_handle_ioctl with + * NVETHERNETRM_PIF$OSI_CMD_READ_MMC IOCTL command periodically. + * + * @param[in] work: + * - work structure + * - The ``work`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Calls NVETHERNETRM_PIF#osi_handle_ioctl with + * NVETHERNETRM_PIF$OSI_CMD_READ_MMC IOCTL command data + * in periodic manner to avoid possibility of + * overrun of 32 bit MMC hw registers. + * + */ +#endif /* DOXYGEN_ICD */ +void ether_stats_work_func(struct work_struct *work); + +/** + * @brief + * Description: + * - Work Queue function to call set speed. + * + * @param[in] work: + * - work structure + * - The ``work`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * + */ +#endif /* DOXYGEN_ICD */ +void set_speed_work_func(struct work_struct *work); + +/** + * @brief + * Description: + * - Gets timestamp and update skb + * + * @param[in] work: + * - Work to handle SKB list update + * - The ``work`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - Parse through tx_ts_skb_head. + * - Issue osi_handle_ioctl(OSI_CMD_GET_TX_TS) to read timestamp. + * - Update skb with timestamp and give to network stack + * - Free skb and node. + * + */ +#endif /* DOXYGEN_ICD */ +void ether_get_tx_ts_work(struct work_struct *work); + +/** + * @brief + * Description: + * - Tasklet to restart the lane bring-up. + * + * @param[in] t: + * - Tasklet structure + * - The ``t`` structure variable is used to retrieve pointers to the private data structure. + * - Used Structure variables: None + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * + */ +#endif /* DOXYGEN_ICD */ +void ether_restart_lane_bringup_task(struct tasklet_struct *t); + +/** + * @brief + * Description: + * - Adjust MAC hardware frequency + * + * @param[in] ptp: + * - Pointer to ptp_clock_info structure. + * @param[in] scaled_ppm: + * - Desired period change in parts per million. + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @return + * - EOK on NVETHERNETRM_PIF$OSI_CMD_ADJ_FREQ IOCTL success + * - Return values of NVETHERNETRM_PIF#osi_handle_ioctl with + * the NVETHERNETRM_PIF$OSI_CMD_ADJ_FREQ IOCTL command. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - This function is used to adjust the frequency of the hardware clock. + * + */ +#endif /* DOXYGEN_ICD */ +int ether_adjust_clock(struct ptp_clock_info *ptp, long scaled_ppm); + +/** + * @brief + * Description: + * - Adjust MAC hardware time + * + * @param[in] ptp: + * - Pointer to ptp_clock_info structure. + * @param[in] nsec_delta: + * - Desired change in nanoseconds w.r.t System time + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @return + * - EOK on NVETHERNETRM_PIF$OSI_CMD_ADJ_TIME IOCTL success + * - Return values of NVETHERNETRM_PIF#osi_handle_ioctl with + * the NVETHERNETRM_PIF$OSI_CMD_ADJ_TIME IOCTL command. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - function is used to shift/adjust the time of the hardware clock. + * + */ +#endif /* DOXYGEN_ICD */ +int ether_adjust_time(struct ptp_clock_info *ptp, s64 nsec_delta); + +/** + * @brief + * Description: + * - Gets current hardware time + * + * @param[in] ptp: + * - Pointer to ptp_clock_info structure. + * @param[in] ts: + * - Pointer to hole time. + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @return + * - EOK on successful read of the hardware time. + * - Return values of NVETHERNETCL_PIF#osi_dma_get_systime_from_mac. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - This function is used to read the current time from the + * hardware clock + * + */ +#endif /* DOXYGEN_ICD */ +int ether_get_time(struct ptp_clock_info *ptp, struct timespec64 *ts); + +/** + * @brief + * Description: + * - Set current system time to MAC Hardware + * - Gets current hardware time + * + * @param[in] ptp: + * - Pointer to ptp_clock_info structure. + * @param[in] ts: + * - Time value to set. + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @return + * - EOK on NVETHERNETRM_PIF$OSI_CMD_SET_SYSTOHW_TIME IOCTL success + * - Return values of NVETHERNETRM_PIF#osi_handle_ioctl with + * the NVETHERNETRM_PIF$OSI_CMD_SET_SYSTOHW_TIME command. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/* + * @note + * Algorithm: + * - This function is used to set the current time to the + * hardware clock. + * + */ +#endif /* DOXYGEN_ICD */ +int ether_set_time(struct ptp_clock_info *ptp, const struct timespec64 *ts); + +/** + * @brief + * Description: + * - Implementing the callback for + * NVETHERNETRM_PIF$osd_core_ops.restart_lane_bringup to restart the lane bringup process. + * + * @param[in] *priv: + * - Pointer to private data structure. + * @param[in] en_disable: + * - Flag to enable (1) or disable (0) the bring-up. + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @dir + * - forward + * + */ +void osd_restart_lane_bringup(void *priv, unsigned int en_disable); + +/** + * @brief + * Description: + * - Implementing the callback for + * NVETHERNETRM_PIF$osd_core_ops.padctrl_mii_rx_pins to restart the PAD calibration process. + * + * @param[in] priv: + * - Pointer to private data structure. + * @param[in] enable: + * - Flag to enable (1) or disable (0) the PAD calibration process. + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @dir + * - forward + * + */ +int ether_padctrl_mii_rx_pins(void *priv, unsigned int enable); + +/** + * @brief + * Description: + * - Implementing the callback for + * NVETHERNETRM_PIF$osd_core_ops.ivc_send to send IVC message. + * + * @param[in] priv: + * - Pointer to private data structure. + * @param[in] ivc_buf: + * - Pointer to NVETHERNETRM_PIF$ivc_msg_common data structure. + * @param[in] len: + * - length of data + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: Yes + * - Run time: Yes + * - De-initialization: Yes + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @return + * - EOK on success + * - "-ETIMEDOUT" on readx_poll_timeout_atomic() timeout. + * - Return vlaues of tegra_hv_ivc_read() on IVC read fail. + * - Return vlaues of tegra_hv_ivc_write() on IVC write fail. + * + * @dir + * - forward + * + */ +int osd_ivc_send_cmd(void *priv, ivc_msg_common_t *ivc_buf, + unsigned int len); + +/** + * @brief + * Description: + * - Implementing the callback for + * NVETHERNETCL_PIF$osd_dma_ops.transmit_complete to report TX done. + * + * @param[in] priv: + * - OSD private data structure. + * @param[in] swcx: + * - Pointer to swcx + * @param[in] txdone_pkt_cx: + * - Pointer to struct which has tx done status info. + * This struct has flags to indicate tx error, whether DMA address + * is mapped from paged/linear buffer. + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @dir + * - forward + * + */ +void osd_transmit_complete(void *priv, const struct osi_tx_swcx *swcx, + const struct osi_txdone_pkt_cx + *txdone_pkt_cx); + +/** + * @brief + * Description: + * - Implementing the callback for + * NVETHERNETCL_PIF$osd_dma_ops.receive_packet to report DMA receive packet. + * + * @param[in] priv: + * - OSD private data structure. + * @param[in] rx_ring: + * - Pointer to DMA channel Rx ring. + * @param[in] chan: + * - DMA Rx channel number. + * @param[in] dma_buf_len: + * - Rx DMA buffer length. + * @param[in] rx_pkt_cx: + * - Received packet context. + * @param[in] rx_swcx: + * - Received packet sw context. + * + * @usage + * - Allowed context for the API call + * - Interrupt: No + * - Signal handler: No + * - Thread-Safe: No + * - Sync/Asyc: Sync + * - Re-entrant: No + * - Required Privileges: None. + * - Operation Mode + * - Initialization: No + * - Run time: Yes + * - De-initialization: No + * + * @pre This should be invoked following a successful + * execution of the NVETHERNET_LINUX_PIF#ether_open event. + * + * @dir + * - forward + * + */ +#ifndef DOXYGEN_ICD +/** + * + * Algorithm: + * 1) Unmap the DMA buffer address. + * 2) Updates socket buffer with len and ether type and handover to + * Linux network stack. + * 3) Refill the Rx ring based on threshold. + * + */ +#endif /* DOXYGEN_ICD */ +void osd_receive_packet(void *priv, struct osi_rx_ring *rx_ring, + unsigned int chan, unsigned int dma_buf_len, + const struct osi_rx_pkt_cx *rx_pkt_cx, + struct osi_rx_swcx *rx_swcx); + + +#endif /* ETHER_CALLBACK_EXPORT_H */ diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_export.h b/drivers/net/ethernet/nvidia/nvethernet/ether_export.h index b8e72a09..e33eb518 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ether_export.h +++ b/drivers/net/ethernet/nvidia/nvethernet/ether_export.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -/* Copyright (c) 2019-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved */ +/* Copyright (c) 2019-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved */ #ifndef ETHER_EXPORT_H #define ETHER_EXPORT_H @@ -13,35 +13,139 @@ * SIOCDEVPRIVATE custom ioctl command. * @{ */ -/** To set HW AVB configuration from user application */ +/** Net device private IOCTL number for time stamp */ +#define ETHER_PRV_TS_IOCTL (SIOCDEVPRIVATE + 1) +/** Private IOCTL number for reading MDIO in the network device. */ +#define ETHER_PRV_RMDIO_IOCTL (SIOCDEVPRIVATE + 2) +/** Private IOCTL number for writing MDIO in the network device. */ +#define ETHER_PRV_WMDIO_IOCTL (SIOCDEVPRIVATE + 3) +/** Get Line speed */ +#define EQOS_GET_CONNECTED_SPEED 25 +/** Set HW AVB configuration from user application */ #define ETHER_AVB_ALGORITHM 27 -/** To get current configuration in HW */ +/** Set L3/L4 filter */ +#define EQOS_L3L4_FILTER_CMD 29 +/** Set VLAN filter */ +#define EQOS_VLAN_FILTERING_CMD 34 +/** Configure ARP offload enable/disable */ +#define ETHER_CONFIG_ARP_OFFLOAD 36 +/** Configure PTP offload enable/disable */ +#define ETHER_CONFIG_PTP_OFFLOAD 42 +/** Get current configuration in HW */ #define ETHER_GET_AVB_ALGORITHM 46 -/** To configure EST(802.1 bv) in HW */ +/** Set PTP RxQ in HW */ +#define ETHER_PTP_RXQUEUE 48 +/** Configure EST(802.1 bv) in HW */ #define ETHER_CONFIG_EST 49 -/** For configure FPE (802.1 bu + 803.2 br) in HW */ +/** Configure FPE (802.1 bu + 803.2 br) in HW */ #define ETHER_CONFIG_FPE 50 -/* FRP command */ +/** Configure FRP rule in HW */ #define ETHER_CONFIG_FRP_CMD 51 -/** To configure L2 Filter (Only with Ethernet virtualization) */ +/** Configure the DMA channel number to route multicast packets in HW */ +#define ETHER_MC_DMA_ROUTE 52 +/** Configure the PAD calibration in HW */ +#define ETHER_PAD_CALIBRATION 55 +/** Configure the TSC PTP in HW */ +#define ETHER_CAP_TSC_PTP 58 +/** Configure the MAC 2 MAC TS sync in HW */ +#define ETHER_M2M_TSYNC 59 +/** Configure L2 Filter (Only with Ethernet virtualization) */ #define ETHER_L2_ADDR 61 /** @} */ /** - * @brief Structure for L2 filters input + *@addtogroup IOCTL Helper MACROS + * @{ + */ +#define NUM_BYTES_IN_IPADDR 4 + +/* PTP offload mode defines */ +/** PTP Ordinary Slave Mode */ +#define ETHER_PTP_ORDINARY_SLAVE 1 +/** PTP Ordinary Master Mode */ +#define ETHER_PTP_ORDINARY_MASTER 2 +/** PTP Transparent Slave Mode */ +#define ETHER_PTP_TRASPARENT_SLAVE 3 +/** PTP Transparent Master Mode */ +#define ETHER_PTP_TRASPARENT_MASTER 4 +/** PTP Transparent Peer Mode */ +#define ETHER_PTP_PEER_TO_PEER_TRANSPARENT 5 +/** @} */ + +/** + * @brief struct to support APR offload + * NVETHERNET_LINUX_PIF$ETHER_CONFIG_ARP_OFFLOAD command + */ +struct arp_offload_param { + /** + * ip_addr: Byte array for decimal representation of IP address. + * - For example, 192.168.1.3 is represented as + * ip_addr[0] = '192' ip_addr[1] = '168' ip_addr[2] = '1' + * ip_addr[3] = '3' + */ + unsigned char ip_addr[NUM_BYTES_IN_IPADDR]; +}; + +/** + * @brief struct to support PTP offload + * NVETHERNET_LINUX_PIF$ETHER_CONFIG_PTP_OFFLOAD command + */ +struct ptp_offload_param { + /** indicates PTP offload status + * - Valid values are enable(1) or disable(0) */ + int en_dis; + /** indicates PTP mode + * - Valid values: + * - NVETHERNET_LINUX_PIF$ETHER_PTP_ORDINARY_MASTER + * - NVETHERNET_LINUX_PIF$ETHER_PTP_ORDINARY_SLAVE + * - NVETHERNET_LINUX_PIF$ETHER_PTP_TRASPARENT_MASTER + * - NVETHERNET_LINUX_PIF$ETHER_PTP_TRASPARENT_SLAVE + * - NVETHERNET_LINUX_PIF$ETHER_PTP_PEER_TO_PEER_TRANSPARENT */ + int mode; + /** ptp domain + * - Valid values: 0 to 0xFF */ + int domain_num; + /** The PTP Offload function qualifies received PTP + * packet with unicast Destination address + * - Valid values: + * - 0 for only multicast + * - 1 for unicast and multicast */ + int mc_uc; +}; + +/** + * @brief struct ifr_data_timestamp_struct - common data structure between + * driver and application for sharing info through private TS ioctl + */ +struct ifr_data_timestamp_struct { + /** Clock ID + * - Expected values are CLOCK_REALTIME or CLOCK_MONOTONIC */ + clockid_t clockid; + /** Store kernel time */ + struct timespec64 kernel_ts; + /** Store HW time */ + struct timespec64 hw_ptp_ts; +}; + + +/** + * @brief Structure for L2 filters NVETHERNET_LINUX_PIF$ETHER_L2_ADDR command */ struct ether_l2_filter { - /** indicates enable(1)/disable(0) L2 filter */ - + /** indicates L2 filter status + * - Expected values are enable(1) or disable(0) */ nveu32_t en_dis; /** Indicates the index of the filter to be modified. - * Filter index must be between 0 - 31 */ + * - Filter index must be between 0 - 127 */ nveu32_t index; /** Ethernet MAC address to be added */ nveu8_t mac_addr[OSI_ETH_ALEN]; - /** packet duplication */ + /** Packet duplication support + * - Expected values are enable(1) or disable(0) */ nveu32_t pkt_dup; - /** dma channel */ + /** dma channel number, values are: + * - from 0 to NVETHERNETRM_PIF$OSI_EQOS_MAX_NUM_CHANS for EQOS + * - from 0 to NVETHERNETRM_PIF$OSI_MGBE_MAX_NUM_CHANS for MGBE */ nveu32_t dma_chan; }; @@ -49,17 +153,43 @@ struct ether_l2_filter { * @brief struct ether_exported_ifr_data - Private data of struct ifreq */ struct ether_exported_ifr_data { - /** Flags used for specific ioctl - like enable/disable */ + /** Flags used for specific ioctl + * - Expected values are enable(1) or disable(0) */ nveu32_t if_flags; - /** qinx: Queue index to be used for certain ioctls */ + /** qinx: Queue index to be used for certain ioctls + * - Valid range: + * - 0 to NVETHERNETRM_PIF$OSI_MGBE_MAX_NUM_QUEUES for MGBE + * - 0 to NVETHERNETRM_PIF$OSI_EQOS_MAX_NUM_QUEUES for EQOS */ nveu32_t qinx; - /** The private ioctl command number */ + /** The private ioctl command number + * - Valid range: should be defined in private IOCTL group + * - Expected values: + * - NVETHERNET_LINUX_PIF$EQOS_GET_CONNECTED_SPEED + * - NVETHERNET_LINUX_PIF$ETHER_AVB_ALGORITHM + * - NVETHERNET_LINUX_PIF$EQOS_L3L4_FILTER_CMD + * - NVETHERNET_LINUX_PIF$EQOS_VLAN_FILTERING_CMD + * - NVETHERNET_LINUX_PIF$ETHER_CONFIG_ARP_OFFLOAD + * - NVETHERNET_LINUX_PIF$ETHER_CONFIG_PTP_OFFLOAD + * - NVETHERNET_LINUX_PIF$ETHER_GET_AVB_ALGORITHM + * - NVETHERNET_LINUX_PIF$ETHER_PTP_RXQUEUE + * - NVETHERNET_LINUX_PIF$ETHER_CONFIG_EST + * - NVETHERNET_LINUX_PIF$ETHER_CONFIG_FPE + * - NVETHERNET_LINUX_PIF$ETHER_CONFIG_FRP_CMD + * - NVETHERNET_LINUX_PIF$ETHER_MC_DMA_ROUTE + * - NVETHERNET_LINUX_PIF$ETHER_PAD_CALIBRATION + * - NVETHERNET_LINUX_PIF$ETHER_CAP_TSC_PTP + * - NVETHERNET_LINUX_PIF$ETHER_M2M_TSYNC + * - NVETHERNET_LINUX_PIF$ETHER_L2_ADDR */ nveu32_t ifcmd; - /** Used to query the connected link speed */ + /** Used to query the connected phy link speed + */ nveu32_t connected_speed; - /** The return value of IOCTL handler func */ + /** The return value of IOCTL handler func + * - Expected values: Linux Error codes */ nve32_t command_error; - /** IOCTL cmd specific structure pointer */ + /** IOCTL cmd specific structure pointer + * - Valid range: A valid pointer to the IOCTL private structure data */ void *ptr; }; + #endif /* ETHER_EXPORT_H */ diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c index 49c64427..aaf62520 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c @@ -142,18 +142,7 @@ update_skb: return ret; } -/** - * @brief Gets timestamp and update skb - * - * Algorithm: - * - Parse through tx_ts_skb_head. - * - Issue osi_handle_ioctl(OSI_CMD_GET_TX_TS) to read timestamp. - * - Update skb with timestamp and give to network stack - * - Free skb and node. - * - * @param[in] work: Work to handle SKB list update - */ -static void ether_get_tx_ts_work(struct work_struct *work) +void ether_get_tx_ts_work(struct work_struct *work) { struct delayed_work *dwork = to_delayed_work(work); struct ether_priv_data *pdata = container_of(dwork, @@ -259,17 +248,7 @@ static irqreturn_t ether_common_isr_thread(int irq, void *data) } #endif -/** - * @brief Work Queue function to call osi_read_mmc() periodically. - * - * Algorithm: call osi_read_mmc in periodic manner to avoid possibility of - * overrun of 32 bit MMC hw registers. - * - * @param[in] work: work structure - * - * @note MAC and PHY need to be initialized. - */ -static inline void ether_stats_work_func(struct work_struct *work) +void ether_stats_work_func(struct work_struct *work) { struct delayed_work *dwork = to_delayed_work(work); struct ether_priv_data *pdata = container_of(dwork, @@ -1229,13 +1208,7 @@ static inline void ether_set_eqos_tx_clk(struct clk *tx_clk, pr_err("%s(): failed to set eqos tx_clk/mac rate\n", __func__); } -/** - * @brief Work Queue function to call set speed. - * - * @param[in] work: work structure - * - */ -static inline void set_speed_work_func(struct work_struct *work) +void set_speed_work_func(struct work_struct *work) { struct delayed_work *dwork = to_delayed_work(work); struct ether_priv_data *pdata = container_of(dwork, @@ -1380,18 +1353,7 @@ static void ether_en_dis_monitor_clks(struct ether_priv_data *pdata, } } -/** - * @brief Adjust link call back - * - * Algorithm: Callback function called by the PHY subsystem - * whenever there is a link detected or link changed on the - * physical layer. - * - * @param[in] dev: Network device data. - * - * @note MAC and PHY need to be initialized. - */ -static void ether_adjust_link(struct net_device *dev) +void ether_adjust_link(struct net_device *dev) { struct ether_priv_data *pdata = netdev_priv(dev); nveu32_t iface_mode = pdata->osi_core->phy_iface_mode; @@ -1667,34 +1629,7 @@ static int ether_phy_init(struct net_device *dev) return 0; } -/** - * @brief ether_vm_isr - VM based ISR routine. - * - * Algorithm: - * 1) Get global DMA status (common for all VM IRQ's) - * + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - * + RX7 + TX7 + RX6 + TX6 + . . . . . . . + RX1 + TX1 + RX0 + TX0 + - * + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - * - * 2) Mask the channels which are specific to VM in global DMA status. - * 3) Process all DMA channel interrupts which are triggered the IRQ - * a) Find first first set from LSB with ffs - * b) The least significant bit is position 1 for ffs. So decremented - * by one to start from zero. - * c) Get channel number and TX/RX info by using bit position. - * d) Invoke OSI layer to clear interrupt source for DMA Tx/Rx at - * DMA and wrapper level. - * e) Get NAPI instance based on channel number and schedule the same. - * - * @param[in] irq: IRQ number. - * @param[in] data: VM IRQ private data structure. - * - * @note MAC and PHY need to be initialized. - * - * @retval IRQ_HANDLED on success. - * @retval IRQ_NONE on failure. - */ -static irqreturn_t ether_vm_isr(int irq, void *data) +irqreturn_t ether_vm_isr(int irq, void *data) { struct ether_vm_irq_data *vm_irq = (struct ether_vm_irq_data *)data; struct ether_priv_data *pdata = vm_irq->pdata; @@ -3029,25 +2964,7 @@ exit: return ret; } -/** - * @brief Call back to handle bring up of Ethernet interface - * - * Algorithm: This routine takes care of below - * 1) PHY initialization - * 2) request tx/rx/common irqs - * 3) HW initialization - * 4) OSD private data structure initialization - * 5) Starting the PHY - * - * @param[in] dev: Net device data structure. - * - * @note Ethernet driver probe need to be completed successfully - * with ethernet network device created. - * - * @retval 0 on success - * @retval "negative value" on failure. - */ -static int ether_open(struct net_device *dev) +int ether_open(struct net_device *dev) { struct ether_priv_data *pdata = netdev_priv(dev); struct osi_core_priv_data *osi_core = pdata->osi_core; @@ -3406,21 +3323,7 @@ static inline void ether_flush_tx_ts_skb_list(struct ether_priv_data *pdata) raw_spin_unlock_irqrestore(&pdata->txts_lock, flags); } -/** - * @brief Call back to handle bring down of Ethernet interface - * - * Algorithm: This routine takes care of below - * 1) Stopping PHY - * 2) Freeing tx/rx/common irqs - * - * @param[in] ndev: Net device data structure. - * - * @note MAC Interface need to be registered. - * - * @retval 0 on success - * @retval "negative value" on failure. - */ -static int ether_close(struct net_device *ndev) +int ether_close(struct net_device *ndev) { struct ether_priv_data *pdata = netdev_priv(ndev); unsigned int chan = 0x0; @@ -3830,24 +3733,9 @@ dma_map_failed: return ret; } -/** - * @brief Select queue based on user priority - * - * Algorithm: - * 1) Select the correct queue index based which has priority of queue - * same as skb->priority - * 2) default select queue array index 0 - * - * @param[in] dev: Network device pointer - * @param[in] skb: sk_buff pointer, buffer data to send - * @param[in] accel_priv: private data used for L2 forwarding offload - * @param[in] fallback: fallback function pointer - * - * @retval "transmit queue index" - */ -static unsigned short ether_select_queue(struct net_device *dev, - struct sk_buff *skb, - struct net_device *sb_dev) +unsigned short ether_select_queue(struct net_device *dev, + struct sk_buff *skb, + struct net_device *sb_dev) { struct ether_priv_data *pdata = netdev_priv(dev); struct osi_core_priv_data *osi_core = pdata->osi_core; @@ -3874,22 +3762,7 @@ static unsigned short ether_select_queue(struct net_device *dev, return txqueue_select; } -/** - * @brief Network layer hook for data transmission. - * - * Algorithm: - * 1) Allocate software context (DMA address for the buffer) for the data. - * 2) Invoke OSI for data transmission. - * - * @param[in] skb: SKB data structure. - * @param[in] ndev: Net device structure. - * - * @note MAC and PHY need to be initialized. - * - * @retval 0 on success - * @retval "negative value" on failure. - */ -static int ether_start_xmit(struct sk_buff *skb, struct net_device *ndev) +int ether_start_xmit(struct sk_buff *skb, struct net_device *ndev) { struct ether_priv_data *pdata = netdev_priv(ndev); struct osi_dma_priv_data *osi_dma = pdata->osi_dma; @@ -4339,23 +4212,7 @@ static int ether_handle_priv_wmdio_ioctl(struct ether_priv_data *pdata, mii_data->val_in); } -/** - * @brief Network stack IOCTL hook to driver - * - * Algorithm: - * 1) Invokes MII API for phy read/write based on IOCTL command - * 2) SIOCDEVPRIVATE for private ioctl - * - * @param[in] dev: network device structure - * @param[in] rq: Interface request structure used for socket - * @param[in] cmd: IOCTL command code - * - * @note Ethernet interface need to be up. - * - * @retval 0 on success - * @retval "negative value" on failure. - */ -static int ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) +int ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { int ret = -EOPNOTSUPP; struct ether_priv_data *pdata; @@ -4439,8 +4296,8 @@ static int ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) } #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) -static int ether_siocdevprivate(struct net_device *dev, struct ifreq *rq, - void __user *data, int cmd) +int ether_siocdevprivate(struct net_device *dev, struct ifreq *rq, + void __user *data, int cmd) { int ret = -EOPNOTSUPP; struct ether_priv_data *pdata; @@ -4519,22 +4376,7 @@ static int ether_set_mac_addr(struct net_device *ndev, void *addr) return ret; } -/** - * @brief Change MAC MTU size - * - * Algorithm: - * 1) Check and return if interface is up. - * 2) Stores new MTU size set by user in OSI core data structure. - * - * @param[in] ndev: Network device structure - * @param[in] new_mtu: New MTU size to set. - * - * @note Ethernet interface need to be down to change MTU size - * - * @retval 0 on success - * @retval "negative value" on failure. - */ -static int ether_change_mtu(struct net_device *ndev, int new_mtu) +int ether_change_mtu(struct net_device *ndev, int new_mtu) { struct ether_priv_data *pdata = netdev_priv(ndev); struct osi_core_priv_data *osi_core = pdata->osi_core; @@ -4585,24 +4427,7 @@ static int ether_change_mtu(struct net_device *ndev, int new_mtu) return 0; } -/** - * @brief Change HW features for the given network device. - * - * Algorithm: - * 1) Check if HW supports feature requested to be changed - * 2) If supported, check the current status of the feature and if it - * needs to be toggled, do so. - * - * @param[in] ndev: Network device structure - * @param[in] feat: New features to be updated - * - * @note Ethernet interface needs to be up. Stack will enforce - * the check. - * - * @retval 0 on success - * @retval "negative value" on failure. - */ -static int ether_set_features(struct net_device *ndev, netdev_features_t feat) +int ether_set_features(struct net_device *ndev, netdev_features_t feat) { int ret = 0; struct ether_priv_data *pdata = netdev_priv(ndev); @@ -4638,27 +4463,7 @@ static int ether_set_features(struct net_device *ndev, netdev_features_t feat) } #ifdef ETHER_VLAN_VID_SUPPORT -/** - * @brief Adds VLAN ID. This function is invoked by upper - * layer when a new VLAN id is registered. This function updates the HW - * filter with new VLAN id. New vlan id can be added with vconfig - - * vconfig add interface_name vlan_id - * - * Algorithm: - * 1) Check for hash or perfect filtering. - * 2) invoke osi call accordingly. - * - * @param[in] ndev: Network device structure - * @param[in] vlan_proto: VLAN proto VLAN_PROTO_8021Q = 0 VLAN_PROTO_8021AD = 1 - * @param[in] vid: VLAN ID. - * - * @note Ethernet interface should be up - * - * @retval 0 on success - * @retval "negative value" on failure. - */ -static int ether_vlan_rx_add_vid(struct net_device *ndev, __be16 vlan_proto, - u16 vid) +int ether_vlan_rx_add_vid(struct net_device *ndev, __be16 vlan_proto, u16 vid) { struct ether_priv_data *pdata = netdev_priv(ndev); struct osi_core_priv_data *osi_core = pdata->osi_core; @@ -4682,27 +4487,7 @@ static int ether_vlan_rx_add_vid(struct net_device *ndev, __be16 vlan_proto, return ret; } -/** - * @brief Removes VLAN ID. This function is invoked by - * upper layer when a new VALN id is removed. This function updates the - * HW filter. vlan id can be removed with vconfig - - * vconfig rem interface_name vlan_id - * - * Algorithm: - * 1) Check for hash or perfect filtering. - * 2) invoke osi call accordingly. - * - * @param[in] ndev: Network device structure - * @param[in] vlan_proto: VLAN proto VLAN_PROTO_8021Q = 0 VLAN_PROTO_8021AD = 1 - * @param[in] vid: VLAN ID. - * - * @note Ethernet interface should be up - * - * @retval 0 on success - * @retval "negative value" on failure. - */ -static int ether_vlan_rx_kill_vid(struct net_device *ndev, __be16 vlan_proto, - u16 vid) +int ether_vlan_rx_kill_vid(struct net_device *ndev, __be16 vlan_proto, u16 vid) { struct ether_priv_data *pdata = netdev_priv(ndev); struct osi_core_priv_data *osi_core = pdata->osi_core; @@ -4727,24 +4512,8 @@ static int ether_vlan_rx_kill_vid(struct net_device *ndev, __be16 vlan_proto, } #endif /* ETHER_VLAN_VID_SUPPORT */ -/** - * @brief ether_setup_tc - TC HW offload support - * - * Algorithm: - * 1) Check the TC setup type - * 2) Call appropriate function based on type. - * - * @param[in] ndev: Network device structure - * @param[in] type: qdisc type - * @param[in] type_data: void pointer having user passed configuration - * - * @note Ethernet interface should be up - * - * @retval 0 on success - * @retval "negative value" on failure. - */ -static int ether_setup_tc(struct net_device *ndev, enum tc_setup_type type, - void *type_data) +int ether_setup_tc(struct net_device *ndev, enum tc_setup_type type, + void *type_data) { struct ether_priv_data *pdata = netdev_priv(ndev); @@ -7392,27 +7161,7 @@ static void ether_init_rss(struct ether_priv_data *pdata, } #endif /* !OSI_STRIPPED_LIB */ -/** - * @brief Ethernet platform driver probe. - * - * Algorithm: - * 1) Get the number of channels from DT. - * 2) Allocate the network device for those many channels. - * 3) Parse MAC and PHY DT. - * 4) Get all required clks/reset/IRQ's. - * 5) Register MDIO bus and network device. - * 6) Initialize spinlock. - * 7) Update filter value based on HW feature. - * 8) Update osi_core->hw_feature with pdata->hw_feat pointer - * 9) Initialize Workqueue to read MMC counters periodically. - * - * @param[in] pdev: platform device associated with platform driver. - * - * @retval 0 on success - * @retval "negative value" on failure - * - */ -static int ether_probe(struct platform_device *pdev) +int ether_probe(struct platform_device *pdev) { struct ether_priv_data *pdata; unsigned int num_dma_chans, mac, macsec, num_mtl_queues, chan, mac_ver_type; @@ -7710,17 +7459,7 @@ err_kzalloc: return ret; } -/** - * @brief Ethernet platform driver remove. - * - * Alogorithm: Release all the resources - * - * @param[in] pdev: Platform device associated with platform driver. - * - * @retval 0 on success - * @retval "negative value" on failure. - */ -static int ether_remove(struct platform_device *pdev) +int ether_remove(struct platform_device *pdev) { struct net_device *ndev = platform_get_drvdata(pdev); struct ether_priv_data *pdata = netdev_priv(ndev); @@ -7760,15 +7499,7 @@ static int ether_remove(struct platform_device *pdev) return 0; } -/** - * @brief Ethernet platform driver shutdown. - * - * Alogorithm: Stops and Deinits PHY, MAC, DMA and Clks hardware and - * release SW allocated resources(buffers, workqueues etc). - * - * @param[in] pdev: Platform device associated with platform driver. - */ -static void ether_shutdown(struct platform_device *pdev) +void ether_shutdown(struct platform_device *pdev) { struct net_device *ndev = platform_get_drvdata(pdev); struct ether_priv_data *pdata = netdev_priv(ndev); @@ -7880,19 +7611,7 @@ err_resume: return ret; } -/** - * @brief Ethernet platform driver suspend noirq callback. - * - * Alogorithm: Stops all data queues and PHY if the device - * does not wake capable. Disable TX and NAPI. - * Deinit OSI core, DMA and TX/RX interrupts. - * - * @param[in] dev: Platform device associated with platform driver. - * - * @retval 0 on success - * @retval "negative value" on failure. - */ -static int ether_suspend_noirq(struct device *dev) +int ether_suspend_noirq(struct device *dev) { struct net_device *ndev = dev_get_drvdata(dev); struct ether_priv_data *pdata = netdev_priv(ndev); @@ -7954,19 +7673,7 @@ static int ether_suspend_noirq(struct device *dev) return 0; } - -/** - * @brief Ethernet platform driver resume noirq callback. - * - * Alogorithm: Enable clocks and call resume sequence, - * refer ether_resume function for resume sequence. - * - * @param[in] dev: Platform device associated with platform driver. - * - * @retval 0 on success - * @retval "negative value" on failure. - */ -static int ether_resume_noirq(struct device *dev) +int ether_resume_noirq(struct device *dev) { struct net_device *ndev = dev_get_drvdata(dev); struct ether_priv_data *pdata = netdev_priv(ndev); diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.h b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.h index d0d545cb..b1fd6687 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.h +++ b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -/* Copyright (c) 2019-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved */ +/* Copyright (c) 2019-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved */ #ifndef ETHER_LINUX_H #define ETHER_LINUX_H @@ -805,13 +805,11 @@ 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) + struct ethtool_test *etest, u64 *buf) { } static inline void ether_selftest_get_strings(struct ether_priv_data *pdata, @@ -839,20 +837,6 @@ static inline int ether_selftest_get_count(struct ether_priv_data *pdata) void ether_assign_osd_ops(struct osi_core_priv_data *osi_core, struct osi_dma_priv_data *osi_dma); -/** - * @brief osd_ivc_send_cmd - OSD ivc send cmd - * - * @param[in] priv: OSD private data - * @param[in] ivc_buf: ivc_msg_common structure - * @param[in] len: length of data - * @note - * API Group: - * - Initialization: Yes - * - Run time: Yes - * - De-initialization: Yes - */ -int osd_ivc_send_cmd(void *priv, ivc_msg_common_t *ivc_buf, - unsigned int len); void ether_set_rx_mode(struct net_device *dev); @@ -920,4 +904,48 @@ void ether_nvgro_purge_timer(struct timer_list *t); #ifdef BW_TEST void ether_tx_bandwidth_work(struct work_struct *work); #endif + +#ifdef ETHER_VLAN_VID_SUPPORT +/** + * @brief Adds VLAN ID. This function is invoked by upper + * layer when a new VLAN id is registered. This function updates the HW + * filter with new VLAN id. New vlan id can be added with vconfig - + * vconfig add interface_name vlan_id + * + * Algorithm: + * 1) Check for hash or perfect filtering. + * 2) invoke osi call accordingly. + * + * @param[in] ndev: Network device structure + * @param[in] vlan_proto: VLAN proto VLAN_PROTO_8021Q = 0 VLAN_PROTO_8021AD = 1 + * @param[in] vid: VLAN ID. + * + * @note Ethernet interface should be up + * + * @retval 0 on success + * @retval "negative value" on failure. + */ +int ether_vlan_rx_add_vid(struct net_device *ndev, __be16 vlan_proto, u16 vid); + +/** + * @brief Removes VLAN ID. This function is invoked by + * upper layer when a new VALN id is removed. This function updates the + * HW filter. vlan id can be removed with vconfig - + * vconfig rem interface_name vlan_id + * + * Algorithm: + * 1) Check for hash or perfect filtering. + * 2) invoke osi call accordingly. + * + * @param[in] ndev: Network device structure + * @param[in] vlan_proto: VLAN proto VLAN_PROTO_8021Q = 0 VLAN_PROTO_8021AD = 1 + * @param[in] vid: VLAN ID. + * + * @note Ethernet interface should be up + * + * @retval 0 on success + * @retval "negative value" on failure. + */ +int ether_vlan_rx_kill_vid(struct net_device *ndev, __be16 vlan_proto, u16 vid); +#endif /* ETHER_VLAN_VID_SUPPORT */ #endif /* ETHER_LINUX_H */ diff --git a/drivers/net/ethernet/nvidia/nvethernet/ethtool.c b/drivers/net/ethernet/nvidia/nvethernet/ethtool.c index 898aa1cb..f7cca24b 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ethtool.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ethtool.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -// SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2019-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. #include @@ -1030,21 +1030,9 @@ static const struct ether_stats ether_tstrings_stats[] = { #endif /* OSI_STRIPPED_LIB */ }; -/** - * @brief This function is invoked by kernel when user requests to get the - * extended statistics about the device. - * - * Algorithm: read mmc register and create strings - * - * @param[in] dev: pointer to net device structure. - * @param[in] dummy: dummy parameter of ethtool_stats type. - * @param[in] data: Pointer in which MMC statistics should be put. - * - * @note Network device needs to created. - */ -static void ether_get_ethtool_stats(struct net_device *dev, - struct ethtool_stats *dummy, - u64 *data) +void ether_get_ethtool_stats(struct net_device *dev, + struct ethtool_stats *dummy, + u64 *data) { struct ether_priv_data *pdata = netdev_priv(dev); struct osi_core_priv_data *osi_core = pdata->osi_core; @@ -1140,19 +1128,7 @@ static void ether_get_ethtool_stats(struct net_device *dev, } } -/** - * @brief This function gets number of strings - * - * Algorithm: return number of strings. - * - * @param[in] dev: Pointer to net device structure. - * @param[in] sset: String set value. - * - * @note Network device needs to created. - * - * @return Numbers of strings(total length) - */ -static int ether_get_sset_count(struct net_device *dev, int sset) +int ether_get_sset_count(struct net_device *dev, int sset) { struct ether_priv_data *pdata = netdev_priv(dev); int len = 0; @@ -1203,19 +1179,7 @@ static int ether_get_sset_count(struct net_device *dev, int sset) return len; } -/** - * @brief This function returns a set of strings that describe - * the requested objects. - * - * Algorithm: return number of strings. - * - * @param[in] dev: Pointer to net device structure. - * @param[in] stringset: String set value. - * @param[in] data: Pointer in which requested string should be put. - * - * @note Network device needs to created. - */ -static void ether_get_strings(struct net_device *dev, u32 stringset, u8 *data) +void ether_get_strings(struct net_device *dev, u32 stringset, u8 *data) { struct ether_priv_data *pdata = netdev_priv(dev); u8 *p = data; @@ -1287,18 +1251,8 @@ static void ether_get_strings(struct net_device *dev, u32 stringset, u8 *data) } #ifndef OSI_STRIPPED_LIB -/** - * @brief Get pause frame settings - * - * Algorithm: Gets pause frame configuration - * - * @param[in] ndev: network device instance - * @param[out] pause: Pause parameters that are set currently - * - * @note Network device needs to created. - */ -static void ether_get_pauseparam(struct net_device *ndev, - struct ethtool_pauseparam *pause) +void ether_get_pauseparam(struct net_device *ndev, + struct ethtool_pauseparam *pause) { struct ether_priv_data *pdata = netdev_priv(ndev); struct phy_device *phydev = pdata->phydev; @@ -1332,21 +1286,8 @@ static void ether_get_pauseparam(struct net_device *ndev, } } -/** - * @brief Set pause frame settings - * - * Algorithm: Sets pause frame settings - * - * @param[in] ndev: network device instance - * @param[in] pause: Pause frame settings - * - * @note Network device needs to created. - * - * @retval 0 on Sucess - * @retval "negative value" on failure. - */ -static int ether_set_pauseparam(struct net_device *ndev, - struct ethtool_pauseparam *pause) +int ether_set_pauseparam(struct net_device *ndev, + struct ethtool_pauseparam *pause) { struct ether_priv_data *pdata = netdev_priv(ndev); struct osi_ioctl ioctl_data = {}; @@ -1889,20 +1830,7 @@ static int ether_set_eee(struct net_device *ndev, return 0; } -/** - * @brief This function is invoked by kernel when user request to set - * pmt parameters for remote wakeup or magic wakeup - * - * Algorithm: Enable or Disable Wake On Lan status based on wol param - * - * @param[in] ndev – pointer to net device structure. - * @param[in] wol – pointer to ethtool_wolinfo structure. - * - * @note MAC and PHY need to be initialized. - * - * @retval zero on success and -ve number on failure. - */ -static int ether_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol) +int ether_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol) { struct ether_priv_data *pdata = netdev_priv(ndev); int ret; @@ -1947,21 +1875,7 @@ static int ether_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol) return ret; } -/** - * @brief This function is invoked by kernel when user request to get report - * whether wake-on-lan is enable or not. - * - * Algorithm: Return Wake On Lan status in wol param - * - * param[in] ndev – pointer to net device structure. - * param[in] wol – pointer to ethtool_wolinfo structure. - * - * @note MAC and PHY need to be initialized. - * - * @retval none - */ - -static void ether_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol) +void ether_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol) { struct ether_priv_data *pdata = netdev_priv(ndev); @@ -1984,23 +1898,9 @@ static void ether_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol) phy_ethtool_get_wol(pdata->phydev, wol); } -/** - * @brief Get RX flow classification rules - * - * Algorithm: Returns RX flow classification rules. - * - * param[in] ndev: Pointer to net device structure. - * param[in] rxnfc: Pointer to rxflow data - * param[in] rule_locs: TBD - * - * @note MAC and PHY need to be initialized. - * - * @retval 0 on success - * @retval negative on failure - */ -static int ether_get_rxnfc(struct net_device *ndev, - struct ethtool_rxnfc *rxnfc, - u32 *rule_locs) +int ether_get_rxnfc(struct net_device *ndev, + struct ethtool_rxnfc *rxnfc, + u32 *rule_locs) { struct ether_priv_data *pdata = netdev_priv(ndev); struct osi_core_priv_data *osi_core = pdata->osi_core; @@ -2016,16 +1916,7 @@ static int ether_get_rxnfc(struct net_device *ndev, return 0; } -/** - * @brief Get the size of the RX flow hash key - * - * Algorithm: Returns size of RSS hash key - * - * param[in] ndev: Pointer to net device structure. - * - * @retval size of RSS Hash key - */ -static u32 ether_get_rxfh_key_size(struct net_device *ndev) +u32 ether_get_rxfh_key_size(struct net_device *ndev) { struct ether_priv_data *pdata = netdev_priv(ndev); struct osi_core_priv_data *osi_core = pdata->osi_core; @@ -2033,16 +1924,7 @@ static u32 ether_get_rxfh_key_size(struct net_device *ndev) return sizeof(osi_core->rss.key); } -/** - * @brief Get the size of the RX flow hash indirection table - * - * Algorithm: Returns size of the RX flow hash indirection table - * - * param[in] ndev: Pointer to net device structure. - * - * @retval size of RSS Hash table - */ -static u32 ether_get_rxfh_indir_size(struct net_device *ndev) +u32 ether_get_rxfh_indir_size(struct net_device *ndev) { struct ether_priv_data *pdata = netdev_priv(ndev); struct osi_core_priv_data *osi_core = pdata->osi_core; @@ -2207,14 +2089,14 @@ static int ether_set_ringparam(struct net_device *ndev, return ret; } -static unsigned int ether_get_msglevel(struct net_device *ndev) +unsigned int ether_get_msglevel(struct net_device *ndev) { struct ether_priv_data *pdata = netdev_priv(ndev); return pdata->msg_enable; } -static void ether_set_msglevel(struct net_device *ndev, u32 level) +void ether_set_msglevel(struct net_device *ndev, u32 level) { struct ether_priv_data *pdata = netdev_priv(ndev); diff --git a/drivers/net/ethernet/nvidia/nvethernet/ioctl.h b/drivers/net/ethernet/nvidia/nvethernet/ioctl.h index fe07df76..97053cf7 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ioctl.h +++ b/drivers/net/ethernet/nvidia/nvethernet/ioctl.h @@ -1,23 +1,41 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -/* Copyright (c) 2019-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved */ +/* Copyright (c) 2019-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved */ #ifndef IOCTL_H #define IOCTL_H #include "ether_export.h" +#include "ether_callback_export.h" + +/** + * @addtogroup private IOCTL related info + * + * @{ + */ +/** Configure loopback mode enable/disable */ +/* Get TX channel/queue count */ +#define EQOS_GET_TX_QCNT 23 +/* Get RX channel/queue count */ +#define EQOS_GET_RX_QCNT 24 +/** Set L2 DA filtering */ +#define EQOS_L2_DA_FILTERING_CMD 35 +#define ETHER_CONFIG_LOOPBACK_MODE 40 +#define ETHER_READ_REG 53 +#define ETHER_WRITE_REG 54 +#ifdef OSI_DEBUG +#define ETHER_REGISTER_DUMP 56 +#define ETHER_STRUCTURE_DUMP 57 +#endif /* OSI_DEBUG */ +#ifdef OSI_DEBUG +#define ETHER_DEBUG_INTR_CONFIG 60 +#endif +/** @} */ + /** *@addtogroup IOCTL Helper MACROS * @{ */ -#define NUM_BYTES_IN_IPADDR 4 #define MAX_IP_ADDR_BYTE 0xFFU -/* PTP offload mode defines */ -#define ETHER_PTP_ORDINARY_SLAVE 1 -#define ETHER_PTP_ORDINARY_MASTER 2 -#define ETHER_PTP_TRASPARENT_SLAVE 3 -#define ETHER_PTP_TRASPARENT_MASTER 4 -#define ETHER_PTP_PEER_TO_PEER_TRANSPARENT 5 - /* class E IP4 addr start range, reserved */ #define CLASS_E_IP4_ADDR_RANGE_START 240U /* class D multicast addr range */ @@ -26,74 +44,8 @@ /* Remote wakeup filter */ #define EQOS_RWK_FILTER_LENGTH 8 -#define ETHER_PRV_TS_IOCTL (SIOCDEVPRIVATE + 1) -#define ETHER_PRV_RMDIO_IOCTL (SIOCDEVPRIVATE + 2) -#define ETHER_PRV_WMDIO_IOCTL (SIOCDEVPRIVATE + 3) -/* private ioctl number*/ -/* TX/RX channel/queue count */ -#define EQOS_GET_TX_QCNT 23 -#define EQOS_GET_RX_QCNT 24 -/** Line speed */ -#define EQOS_GET_CONNECTED_SPEED 25 -/* L3/L4 filter */ -#define EQOS_L3L4_FILTER_CMD 29 -/* VLAN filtering */ -#define EQOS_VLAN_FILTERING_CMD 34 -/* L2 DA filtering */ -#define EQOS_L2_DA_FILTERING_CMD 35 -#define ETHER_CONFIG_ARP_OFFLOAD 36 -#define ETHER_CONFIG_LOOPBACK_MODE 40 -#define ETHER_CONFIG_PTP_OFFLOAD 42 -#define ETHER_PTP_RXQUEUE 48 -#define ETHER_MC_DMA_ROUTE 52 -#define ETHER_READ_REG 53 -#define ETHER_WRITE_REG 54 -#define ETHER_PAD_CALIBRATION 55 -#ifdef OSI_DEBUG -#define ETHER_REGISTER_DUMP 56 -#define ETHER_STRUCTURE_DUMP 57 -#endif /* OSI_DEBUG */ -#define ETHER_CAP_TSC_PTP 58 -#define ETHER_M2M_TSYNC 59 -#ifdef OSI_DEBUG -#define ETHER_DEBUG_INTR_CONFIG 60 -#endif /** @} */ -/** - * @brief struct arp_offload_param - Parameter to support ARP offload. - */ -struct arp_offload_param { - /** ip_addr: Byte array for decimal representation of IP address. - * For example, 192.168.1.3 is represented as - * ip_addr[0] = '192' ip_addr[1] = '168' ip_addr[2] = '1' - * ip_addr[3] = '3' */ - unsigned char ip_addr[NUM_BYTES_IN_IPADDR]; -}; - -/** - * @brief struct ptp_offload_param - Parameter to support PTP offload. - */ -struct ptp_offload_param { - int en_dis; - int mode; - int domain_num; - int mc_uc; -}; - -/** - * @brief struct ifr_data_timestamp_struct - common data structure between - * driver and application for sharing info through private TS ioctl - */ -struct ifr_data_timestamp_struct { - /** Clock ID */ - clockid_t clockid; - /** Store kernel time */ - struct timespec64 kernel_ts; - /** Store HW time */ - struct timespec64 hw_ptp_ts; -}; - /** * @brief ether_priv_ioctl - Handle private IOCTLs * Algorithm: diff --git a/drivers/net/ethernet/nvidia/nvethernet/osd.c b/drivers/net/ethernet/nvidia/nvethernet/osd.c index 69d8c972..d55d4f1f 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/osd.c +++ b/drivers/net/ethernet/nvidia/nvethernet/osd.c @@ -576,28 +576,10 @@ exit: } #endif -/** - * @brief Handover received packet to network stack. - * - * Algorithm: - * 1) Unmap the DMA buffer address. - * 2) Updates socket buffer with len and ether type and handover to - * Linux network stack. - * 3) Refill the Rx ring based on threshold. - * - * @param[in] priv: OSD private data structure. - * @param[in] rx_ring: Pointer to DMA channel Rx ring. - * @param[in] chan: DMA Rx channel number. - * @param[in] dma_buf_len: Rx DMA buffer length. - * @param[in] rx_pkt_cx: Received packet context. - * @param[in] rx_swcx: Received packet sw context. - * - * @note Rx completion need to make sure that Rx descriptors processed properly. - */ -static void osd_receive_packet(void *priv, struct osi_rx_ring *rx_ring, - unsigned int chan, unsigned int dma_buf_len, - const struct osi_rx_pkt_cx *rx_pkt_cx, - struct osi_rx_swcx *rx_swcx) +void osd_receive_packet(void *priv, struct osi_rx_ring *rx_ring, + unsigned int chan, unsigned int dma_buf_len, + const struct osi_rx_pkt_cx *rx_pkt_cx, + struct osi_rx_swcx *rx_swcx) { struct ether_priv_data *pdata = (struct ether_priv_data *)priv; struct osi_core_priv_data *osi_core = pdata->osi_core; @@ -726,25 +708,9 @@ done: ether_realloc_rx_skb(pdata, rx_ring, chan); } -/** - * @brief osd_transmit_complete - Transmit completion routine. - * - * Algorithm: - * 1) Updates stats for linux network stack. - * 2) unmap and free the buffer DMA address and buffer. - * 3) Time stamp will be update to stack if available. - * - * @param[in] priv: OSD private data structure. - * @param[in] swcx: Pointer to swcx - * @param[in] txdone_pkt_cx: Pointer to struct which has tx done status info. - * This struct has flags to indicate tx error, whether DMA address - * is mapped from paged/linear buffer. - * - * @note Tx completion need to make sure that Tx descriptors processed properly. - */ -static void osd_transmit_complete(void *priv, const struct osi_tx_swcx *swcx, - const struct osi_txdone_pkt_cx - *txdone_pkt_cx) +void osd_transmit_complete(void *priv, const struct osi_tx_swcx *swcx, + const struct osi_txdone_pkt_cx + *txdone_pkt_cx) { struct ether_priv_data *pdata = (struct ether_priv_data *)priv; struct osi_dma_priv_data *osi_dma = pdata->osi_dma; @@ -912,7 +878,7 @@ void ether_restart_lane_bringup_task(struct tasklet_struct *t) } } -static void osd_restart_lane_bringup(void *priv, unsigned int en_disable) +void osd_restart_lane_bringup(void *priv, unsigned int en_disable) { struct ether_priv_data *pdata = (struct ether_priv_data *)priv; diff --git a/drivers/net/ethernet/nvidia/nvethernet/ptp.c b/drivers/net/ethernet/nvidia/nvethernet/ptp.c index ab9a8ac8..366bf9c6 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ptp.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ptp.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -// SPDX-FileCopyrightText: Copyright (c) 2019-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2019-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. #include "ether_linux.h" @@ -78,19 +78,7 @@ static inline int ether_get_hw_time(struct net_device *dev, return 0; } -/** - * @brief Adjust MAC hardware time - * - * Algorithm: This function is used to shift/adjust the time of the - * hardware clock. - * - * @param[in] ptp: Pointer to ptp_clock_info structure. - * @param[in] nsec_delta: Desired change in nanoseconds w.r.t System time - * - * @retval 0 on success - * @retval "negative value" on failure. - */ -static int ether_adjust_time(struct ptp_clock_info *ptp, s64 nsec_delta) +int ether_adjust_time(struct ptp_clock_info *ptp, s64 nsec_delta) { struct ether_priv_data *pdata = container_of(ptp, struct ether_priv_data, @@ -116,20 +104,7 @@ static int ether_adjust_time(struct ptp_clock_info *ptp, s64 nsec_delta) return ret; } -/** - * @brief Adjust MAC hardware frequency - * - * Algorithm: This function is used to adjust the frequency of the - * hardware clock. - * - * @param[in] ptp: Pointer to ptp_clock_info structure. - * @param[in] ppb: Desired period change in parts per billion. - * @param[in] scaled_ppm: Desired period change in parts per million. - * - * @retval 0 on success - * @retval "negative value" on failure. - */ -static int ether_adjust_clock(struct ptp_clock_info *ptp, long scaled_ppm) +int ether_adjust_clock(struct ptp_clock_info *ptp, long scaled_ppm) { struct ether_priv_data *pdata = container_of(ptp, struct ether_priv_data, @@ -155,19 +130,7 @@ static int ether_adjust_clock(struct ptp_clock_info *ptp, long scaled_ppm) return ret; } -/** - * @brief Gets current hardware time - * - * Algorithm: This function is used to read the current time from the - * hardware clock - * - * @param[in] ptp: Pointer to ptp_clock_info structure. - * @param[in] ts: Pointer to hole time. - * - * @retval 0 on success - * @retval "negative value" on failure. - */ -static int ether_get_time(struct ptp_clock_info *ptp, struct timespec64 *ts) +int ether_get_time(struct ptp_clock_info *ptp, struct timespec64 *ts) { struct ether_priv_data *pdata = container_of(ptp, struct ether_priv_data, @@ -194,20 +157,7 @@ static int ether_get_time(struct ptp_clock_info *ptp, struct timespec64 *ts) return 0; } -/** - * @brief Set current system time to MAC Hardware - * - * Algorithm: This function is used to set the current time to the - * hardware clock. - * - * @param[in] ptp: Pointer to ptp_clock_info structure. - * @param[in] ts: Time value to set. - * - * @retval 0 on success - * @retval "negative value" on failure. - */ -static int ether_set_time(struct ptp_clock_info *ptp, - const struct timespec64 *ts) +int ether_set_time(struct ptp_clock_info *ptp, const struct timespec64 *ts) { struct ether_priv_data *pdata = container_of(ptp, struct ether_priv_data, diff --git a/drivers/net/ethernet/nvidia/nvethernet/selftests.c b/drivers/net/ethernet/nvidia/nvethernet/selftests.c index a8ca10bd..ef34c928 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/selftests.c +++ b/drivers/net/ethernet/nvidia/nvethernet/selftests.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2019-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved */ +/* Copyright (c) 2019-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved */ #ifndef OSI_STRIPPED_LIB #include "ether_linux.h" @@ -371,16 +371,6 @@ static const struct ether_test { }, }; -/** - * @brief ether_selftest_run - Ethernet selftests. - * - * @param[in] dev: Network device pointer. - * @param[in] etest: Ethernet ethtool test pointer. - * @param[in] buf: Buffer pointer to hold test status. - * - * @retval zero on success. - * @retval negative value on failure. - */ void ether_selftest_run(struct net_device *dev, struct ethtool_test *etest, u64 *buf) {