diff options
Diffstat (limited to '')
-rw-r--r-- | drivers/net/ethernet/cavium/liquidio/lio_vf_main.c | 289 |
1 files changed, 152 insertions, 137 deletions
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c index 7a77544a54f5..ac196883f07e 100644 --- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c +++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c @@ -32,7 +32,6 @@ MODULE_AUTHOR("Cavium Networks, <support@cavium.com>"); MODULE_DESCRIPTION("Cavium LiquidIO Intelligent Server Adapter Virtual Function Driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(LIQUIDIO_VERSION); static int debug = -1; module_param(debug, int, 0644); @@ -100,8 +99,8 @@ static int lio_wait_for_oq_pkts(struct octeon_device *oct) } /** - * \brief Cause device to go quiet so it can be safely removed/reset/etc - * @param oct Pointer to Octeon device + * pcierror_quiesce_device - Cause device to go quiet so it can be safely removed/reset/etc + * @oct: Pointer to Octeon device */ static void pcierror_quiesce_device(struct octeon_device *oct) { @@ -144,8 +143,8 @@ static void pcierror_quiesce_device(struct octeon_device *oct) } /** - * \brief Cleanup PCI AER uncorrectable error status - * @param dev Pointer to PCI device + * cleanup_aer_uncorrect_error_status - Cleanup PCI AER uncorrectable error status + * @dev: Pointer to PCI device */ static void cleanup_aer_uncorrect_error_status(struct pci_dev *dev) { @@ -164,8 +163,8 @@ static void cleanup_aer_uncorrect_error_status(struct pci_dev *dev) } /** - * \brief Stop all PCI IO to a given device - * @param dev Pointer to Octeon device + * stop_pci_io - Stop all PCI IO to a given device + * @oct: Pointer to Octeon device */ static void stop_pci_io(struct octeon_device *oct) { @@ -206,9 +205,9 @@ static void stop_pci_io(struct octeon_device *oct) } /** - * \brief called when PCI error is detected - * @param pdev Pointer to PCI device - * @param state The current pci connection state + * liquidio_pcie_error_detected - called when PCI error is detected + * @pdev: Pointer to PCI device + * @state: The current pci connection state * * This function is called after a PCI bus error affecting * this device has been detected. @@ -257,8 +256,8 @@ static struct pci_driver liquidio_vf_pci_driver = { }; /** - * \brief Print link information - * @param netdev network device + * print_link_info - Print link information + * @netdev: network device */ static void print_link_info(struct net_device *netdev) { @@ -279,8 +278,8 @@ static void print_link_info(struct net_device *netdev) } /** - * \brief Routine to notify MTU change - * @param work work_struct data structure + * octnet_link_status_change - Routine to notify MTU change + * @work: work_struct data structure */ static void octnet_link_status_change(struct work_struct *work) { @@ -297,8 +296,8 @@ static void octnet_link_status_change(struct work_struct *work) } /** - * \brief Sets up the mtu status change work - * @param netdev network device + * setup_link_status_change_wq - Sets up the mtu status change work + * @netdev: network device */ static int setup_link_status_change_wq(struct net_device *netdev) { @@ -329,9 +328,9 @@ static void cleanup_link_status_change_wq(struct net_device *netdev) } /** - * \brief Update link status - * @param netdev network device - * @param ls link status structure + * update_link_status - Update link status + * @netdev: network device + * @ls: link status structure * * Called on receipt of a link status response from the core application to * update each interface's link status. @@ -375,13 +374,13 @@ static void update_link_status(struct net_device *netdev, } /** - * \brief PCI probe handler - * @param pdev PCI device structure - * @param ent unused + * liquidio_vf_probe - PCI probe handler + * @pdev: PCI device structure + * @ent: unused */ static int liquidio_vf_probe(struct pci_dev *pdev, - const struct pci_device_id *ent __attribute__((unused))) + const struct pci_device_id __maybe_unused *ent) { struct octeon_device *oct_dev = NULL; @@ -417,8 +416,8 @@ liquidio_vf_probe(struct pci_dev *pdev, } /** - * \brief PCI FLR for each Octeon device. - * @param oct octeon device + * octeon_pci_flr - PCI FLR for each Octeon device. + * @oct: octeon device */ static void octeon_pci_flr(struct octeon_device *oct) { @@ -438,9 +437,8 @@ static void octeon_pci_flr(struct octeon_device *oct) } /** - *\brief Destroy resources associated with octeon device - * @param pdev PCI device structure - * @param ent unused + * octeon_destroy_resources - Destroy resources associated with octeon device + * @oct: octeon device */ static void octeon_destroy_resources(struct octeon_device *oct) { @@ -461,9 +459,8 @@ static void octeon_destroy_resources(struct octeon_device *oct) schedule_timeout_uninterruptible(HZ / 10); - /* fallthrough */ + fallthrough; case OCT_DEV_HOST_OK: - /* fallthrough */ case OCT_DEV_IO_QUEUES_DONE: if (lio_wait_for_instr_fetch(oct)) dev_err(&oct->pci_dev->dev, "IQ had pending instructions\n"); @@ -505,7 +502,7 @@ static void octeon_destroy_resources(struct octeon_device *oct) octeon_free_sc_done_list(oct); octeon_free_sc_zombie_list(oct); - /* fall through */ + fallthrough; case OCT_DEV_INTR_SET_DONE: /* Disable interrupts */ oct->fn_list.disable_interrupt(oct, OCTEON_ALL_INTR); @@ -529,20 +526,20 @@ static void octeon_destroy_resources(struct octeon_device *oct) oct->irq_name_storage = NULL; } /* Soft reset the octeon device before exiting */ - if (oct->pci_dev->reset_fn) + if (!pcie_reset_flr(oct->pci_dev, PCI_RESET_PROBE)) octeon_pci_flr(oct); else cn23xx_vf_ask_pf_to_do_flr(oct); - /* fallthrough */ + fallthrough; case OCT_DEV_MSIX_ALLOC_VECTOR_DONE: octeon_free_ioq_vector(oct); - /* fallthrough */ + fallthrough; case OCT_DEV_MBOX_SETUP_DONE: oct->fn_list.free_mbox(oct); - /* fallthrough */ + fallthrough; case OCT_DEV_IN_RESET: case OCT_DEV_DROQ_INIT_DONE: mdelay(100); @@ -552,11 +549,11 @@ static void octeon_destroy_resources(struct octeon_device *oct) octeon_delete_droq(oct, i); } - /* fallthrough */ + fallthrough; case OCT_DEV_RESP_LIST_INIT_DONE: octeon_delete_response_list(oct); - /* fallthrough */ + fallthrough; case OCT_DEV_INSTR_QUEUE_INIT_DONE: for (i = 0; i < MAX_OCTEON_INSTR_QUEUES(oct); i++) { if (!(oct->io_qmask.iq & BIT_ULL(i))) @@ -564,27 +561,27 @@ static void octeon_destroy_resources(struct octeon_device *oct) octeon_delete_instr_queue(oct, i); } - /* fallthrough */ + fallthrough; case OCT_DEV_SC_BUFF_POOL_INIT_DONE: octeon_free_sc_buffer_pool(oct); - /* fallthrough */ + fallthrough; case OCT_DEV_DISPATCH_INIT_DONE: octeon_delete_dispatch_list(oct); cancel_delayed_work_sync(&oct->nic_poll_work.work); - /* fallthrough */ + fallthrough; case OCT_DEV_PCI_MAP_DONE: octeon_unmap_pci_barx(oct, 0); octeon_unmap_pci_barx(oct, 1); - /* fallthrough */ + fallthrough; case OCT_DEV_PCI_ENABLE_DONE: pci_clear_master(oct->pci_dev); /* Disable the device, releasing the PCI INT */ pci_disable_device(oct->pci_dev); - /* fallthrough */ + fallthrough; case OCT_DEV_BEGIN_STATE: /* Nothing to be done here either */ break; @@ -594,11 +591,11 @@ static void octeon_destroy_resources(struct octeon_device *oct) } /** - * \brief Send Rx control command - * @param lio per-network private data - * @param start_stop whether to start or stop + * send_rx_ctrl_cmd - Send Rx control command + * @lio: per-network private data + * @start_stop: whether to start or stop */ -static void send_rx_ctrl_cmd(struct lio *lio, int start_stop) +static int send_rx_ctrl_cmd(struct lio *lio, int start_stop) { struct octeon_device *oct = (struct octeon_device *)lio->oct_dev; struct octeon_soft_command *sc; @@ -606,11 +603,16 @@ static void send_rx_ctrl_cmd(struct lio *lio, int start_stop) int retval; if (oct->props[lio->ifidx].rx_on == start_stop) - return; + return 0; sc = (struct octeon_soft_command *) octeon_alloc_soft_command(oct, OCTNET_CMD_SIZE, 16, 0); + if (!sc) { + netif_info(lio, rx_err, lio->netdev, + "Failed to allocate octeon_soft_command struct\n"); + return -ENOMEM; + } ncmd = (union octnet_cmd *)sc->virtdptr; @@ -638,17 +640,19 @@ static void send_rx_ctrl_cmd(struct lio *lio, int start_stop) */ retval = wait_for_sc_completion_timeout(oct, sc, 0); if (retval) - return; + return retval; oct->props[lio->ifidx].rx_on = start_stop; WRITE_ONCE(sc->caller_is_done, true); } + + return retval; } /** - * \brief Destroy NIC device interface - * @param oct octeon device - * @param ifidx which interface to destroy + * liquidio_destroy_nic_device - Destroy NIC device interface + * @oct: octeon device + * @ifidx: which interface to destroy * * Cleanup associated with each interface for an Octeon device when NIC * module is being unloaded or if initialization fails during load. @@ -706,8 +710,8 @@ static void liquidio_destroy_nic_device(struct octeon_device *oct, int ifidx) } /** - * \brief Stop complete NIC functionality - * @param oct octeon device + * liquidio_stop_nic_module - Stop complete NIC functionality + * @oct: octeon device */ static int liquidio_stop_nic_module(struct octeon_device *oct) { @@ -739,8 +743,8 @@ static int liquidio_stop_nic_module(struct octeon_device *oct) } /** - * \brief Cleans up resources at unload time - * @param pdev PCI device structure + * liquidio_vf_remove - Cleans up resources at unload time + * @pdev: PCI device structure */ static void liquidio_vf_remove(struct pci_dev *pdev) { @@ -765,8 +769,8 @@ static void liquidio_vf_remove(struct pci_dev *pdev) } /** - * \brief PCI initialization for each Octeon device. - * @param oct octeon device + * octeon_pci_os_setup - PCI initialization for each Octeon device. + * @oct: octeon device */ static int octeon_pci_os_setup(struct octeon_device *oct) { @@ -794,8 +798,8 @@ static int octeon_pci_os_setup(struct octeon_device *oct) } /** - * \brief Unmap and free network buffer - * @param buf buffer + * free_netbuf - Unmap and free network buffer + * @buf: buffer */ static void free_netbuf(void *buf) { @@ -814,8 +818,8 @@ static void free_netbuf(void *buf) } /** - * \brief Unmap and free gather buffer - * @param buf buffer + * free_netsgbuf - Unmap and free gather buffer + * @buf: buffer */ static void free_netsgbuf(void *buf) { @@ -839,7 +843,7 @@ static void free_netsgbuf(void *buf) while (frags--) { skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1]; - pci_unmap_page((lio->oct_dev)->pci_dev, + dma_unmap_page(&lio->oct_dev->pci_dev->dev, g->sg[(i >> 2)].ptr[(i & 3)], skb_frag_size(frag), DMA_TO_DEVICE); i++; @@ -855,8 +859,8 @@ static void free_netsgbuf(void *buf) } /** - * \brief Unmap and free gather buffer with response - * @param buf buffer + * free_netsgbuf_with_resp - Unmap and free gather buffer with response + * @buf: buffer */ static void free_netsgbuf_with_resp(void *buf) { @@ -883,7 +887,7 @@ static void free_netsgbuf_with_resp(void *buf) while (frags--) { skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1]; - pci_unmap_page((lio->oct_dev)->pci_dev, + dma_unmap_page(&lio->oct_dev->pci_dev->dev, g->sg[(i >> 2)].ptr[(i & 3)], skb_frag_size(frag), DMA_TO_DEVICE); i++; @@ -899,8 +903,8 @@ static void free_netsgbuf_with_resp(void *buf) } /** - * \brief Net device open for LiquidIO - * @param netdev network device + * liquidio_open - Net device open for LiquidIO + * @netdev: network device */ static int liquidio_open(struct net_device *netdev) { @@ -909,6 +913,7 @@ static int liquidio_open(struct net_device *netdev) struct octeon_device_priv *oct_priv = (struct octeon_device_priv *)oct->priv; struct napi_struct *napi, *n; + int ret = 0; if (!oct->props[lio->ifidx].napi_enabled) { tasklet_disable(&oct_priv->droq_tasklet); @@ -935,16 +940,18 @@ static int liquidio_open(struct net_device *netdev) (LIQUIDIO_NDEV_STATS_POLL_TIME_MS)); /* tell Octeon to start forwarding packets to host */ - send_rx_ctrl_cmd(lio, 1); + ret = send_rx_ctrl_cmd(lio, 1); + if (ret) + return ret; dev_info(&oct->pci_dev->dev, "%s interface is opened\n", netdev->name); - return 0; + return ret; } /** - * \brief Net device stop for LiquidIO - * @param netdev network device + * liquidio_stop - jNet device stop for LiquidIO + * @netdev: network device */ static int liquidio_stop(struct net_device *netdev) { @@ -953,9 +960,12 @@ static int liquidio_stop(struct net_device *netdev) struct octeon_device_priv *oct_priv = (struct octeon_device_priv *)oct->priv; struct napi_struct *napi, *n; + int ret = 0; /* tell Octeon to stop forwarding packets to host */ - send_rx_ctrl_cmd(lio, 0); + ret = send_rx_ctrl_cmd(lio, 0); + if (ret) + return ret; netif_info(lio, ifdown, lio->netdev, "Stopping interface!\n"); /* Inform that netif carrier is down */ @@ -989,12 +999,12 @@ static int liquidio_stop(struct net_device *netdev) dev_info(&oct->pci_dev->dev, "%s interface is stopped\n", netdev->name); - return 0; + return ret; } /** - * \brief Converts a mask based on net device flags - * @param netdev network device + * get_new_flags - Converts a mask based on net device flags + * @netdev: network device * * This routine generates a octnet_ifflags mask from the net device flags * received from the OS. @@ -1062,8 +1072,8 @@ static void liquidio_set_uc_list(struct net_device *netdev) } /** - * \brief Net device set_multicast_list - * @param netdev network device + * liquidio_set_mcast_list - Net device set_multicast_list + * @netdev: network device */ static void liquidio_set_mcast_list(struct net_device *netdev) { @@ -1112,8 +1122,9 @@ static void liquidio_set_mcast_list(struct net_device *netdev) } /** - * \brief Net device set_mac_address - * @param netdev network device + * liquidio_set_mac - Net device set_mac_address + * @netdev: network device + * @p: opaque pointer to sockaddr */ static int liquidio_set_mac(struct net_device *netdev, void *p) { @@ -1157,7 +1168,7 @@ static int liquidio_set_mac(struct net_device *netdev, void *p) return -EPERM; } - memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); + eth_hw_addr_set(netdev, addr->sa_data); ether_addr_copy(((u8 *)&lio->linfo.hw_addr) + 2, addr->sa_data); return 0; @@ -1231,10 +1242,9 @@ liquidio_get_stats64(struct net_device *netdev, } /** - * \brief Handler for SIOCSHWTSTAMP ioctl - * @param netdev network device - * @param ifr interface request - * @param cmd command + * hwtstamp_ioctl - Handler for SIOCSHWTSTAMP ioctl + * @netdev: network device + * @ifr: interface request */ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr) { @@ -1244,9 +1254,6 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr) if (copy_from_user(&conf, ifr->ifr_data, sizeof(conf))) return -EFAULT; - if (conf.flags) - return -EINVAL; - switch (conf.tx_type) { case HWTSTAMP_TX_ON: case HWTSTAMP_TX_OFF: @@ -1289,10 +1296,10 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr) } /** - * \brief ioctl handler - * @param netdev network device - * @param ifr interface request - * @param cmd command + * liquidio_ioctl - ioctl handler + * @netdev: network device + * @ifr: interface request + * @cmd: command */ static int liquidio_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) { @@ -1341,10 +1348,10 @@ static void handle_timestamp(struct octeon_device *oct, u32 status, void *buf) tx_buffer_free(skb); } -/* \brief Send a data packet that will be timestamped - * @param oct octeon device - * @param ndata pointer to network data - * @param finfo pointer to private network data +/* send_nic_timestamp_pkt - Send a data packet that will be timestamped + * @oct: octeon device + * @ndata: pointer to network data + * @finfo: pointer to private network data */ static int send_nic_timestamp_pkt(struct octeon_device *oct, struct octnic_data_pkt *ndata, @@ -1395,9 +1402,10 @@ static int send_nic_timestamp_pkt(struct octeon_device *oct, return retval; } -/** \brief Transmit networks packets to the Octeon interface - * @param skbuff skbuff struct to be passed to network layer. - * @param netdev pointer to network device +/** + * liquidio_xmit - Transmit networks packets to the Octeon interface + * @skb: skbuff struct to be passed to network layer. + * @netdev: pointer to network device * @returns whether the packet was transmitted to the device okay or not * (NETDEV_TX_OK or NETDEV_TX_BUSY) */ @@ -1625,8 +1633,10 @@ lio_xmit_failed: return NETDEV_TX_OK; } -/** \brief Network device Tx timeout - * @param netdev pointer to network device +/** + * liquidio_tx_timeout - Network device Tx timeout + * @netdev: pointer to network device + * @txqueue: index of the hung transmit queue */ static void liquidio_tx_timeout(struct net_device *netdev, unsigned int txqueue) { @@ -1768,6 +1778,35 @@ static int liquidio_vxlan_port_command(struct net_device *netdev, int command, return ret; } +static int liquidio_udp_tunnel_set_port(struct net_device *netdev, + unsigned int table, unsigned int entry, + struct udp_tunnel_info *ti) +{ + return liquidio_vxlan_port_command(netdev, + OCTNET_CMD_VXLAN_PORT_CONFIG, + htons(ti->port), + OCTNET_CMD_VXLAN_PORT_ADD); +} + +static int liquidio_udp_tunnel_unset_port(struct net_device *netdev, + unsigned int table, + unsigned int entry, + struct udp_tunnel_info *ti) +{ + return liquidio_vxlan_port_command(netdev, + OCTNET_CMD_VXLAN_PORT_CONFIG, + htons(ti->port), + OCTNET_CMD_VXLAN_PORT_DEL); +} + +static const struct udp_tunnel_nic_info liquidio_udp_tunnels = { + .set_port = liquidio_udp_tunnel_set_port, + .unset_port = liquidio_udp_tunnel_unset_port, + .tables = { + { .n_entries = 1024, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, }, + }, +}; + /** \brief Net device fix features * @param netdev pointer to network device * @param request features requested @@ -1836,30 +1875,6 @@ static int liquidio_set_features(struct net_device *netdev, return 0; } -static void liquidio_add_vxlan_port(struct net_device *netdev, - struct udp_tunnel_info *ti) -{ - if (ti->type != UDP_TUNNEL_TYPE_VXLAN) - return; - - liquidio_vxlan_port_command(netdev, - OCTNET_CMD_VXLAN_PORT_CONFIG, - htons(ti->port), - OCTNET_CMD_VXLAN_PORT_ADD); -} - -static void liquidio_del_vxlan_port(struct net_device *netdev, - struct udp_tunnel_info *ti) -{ - if (ti->type != UDP_TUNNEL_TYPE_VXLAN) - return; - - liquidio_vxlan_port_command(netdev, - OCTNET_CMD_VXLAN_PORT_CONFIG, - htons(ti->port), - OCTNET_CMD_VXLAN_PORT_DEL); -} - static const struct net_device_ops lionetdevops = { .ndo_open = liquidio_open, .ndo_stop = liquidio_stop, @@ -1871,11 +1886,9 @@ static const struct net_device_ops lionetdevops = { .ndo_vlan_rx_add_vid = liquidio_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = liquidio_vlan_rx_kill_vid, .ndo_change_mtu = liquidio_change_mtu, - .ndo_do_ioctl = liquidio_ioctl, + .ndo_eth_ioctl = liquidio_ioctl, .ndo_fix_features = liquidio_fix_features, .ndo_set_features = liquidio_set_features, - .ndo_udp_tunnel_add = liquidio_add_vxlan_port, - .ndo_udp_tunnel_del = liquidio_del_vxlan_port, }; static int lio_nic_info(struct octeon_recv_info *recv_info, void *buf) @@ -1914,8 +1927,8 @@ nic_info_err: } /** - * \brief Setup network interfaces - * @param octeon_dev octeon device + * setup_nic_devices - Setup network interfaces + * @octeon_dev: octeon device * * Called during init time for each device. It assumes the NIC * is already up and running. The link information for each @@ -2081,7 +2094,7 @@ static int setup_nic_devices(struct octeon_device *octeon_dev) | NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_GRO | NETIF_F_LRO; - netif_set_gso_max_size(netdev, OCTNIC_GSO_MAX_SIZE); + netif_set_tso_max_size(netdev, OCTNIC_GSO_MAX_SIZE); /* Copy of transmit encapsulation capabilities: * TSO, TSO6, Checksums for this device @@ -2096,6 +2109,8 @@ static int setup_nic_devices(struct octeon_device *octeon_dev) netdev->hw_enc_features = (lio->enc_dev_capability & ~NETIF_F_LRO); + netdev->udp_tunnel_nic_info = &liquidio_udp_tunnels; + netdev->vlan_features = lio->dev_capability; /* Add any unchangeable hw features */ lio->dev_capability |= NETIF_F_HW_VLAN_CTAG_FILTER | @@ -2130,7 +2145,7 @@ static int setup_nic_devices(struct octeon_device *octeon_dev) mac[j] = *((u8 *)(((u8 *)&lio->linfo.hw_addr) + 2 + j)); /* Copy MAC Address to OS network device structure */ - ether_addr_copy(netdev->dev_addr, mac); + eth_hw_addr_set(netdev, mac); if (liquidio_setup_io_queues(octeon_dev, i, lio->linfo.num_txpciq, @@ -2224,8 +2239,8 @@ setup_nic_dev_done: } /** - * \brief initialize the NIC - * @param oct octeon device + * liquidio_init_nic_module - initialize the NIC + * @oct: octeon device * * This initialization routine is called once the Octeon device application is * up and running @@ -2265,8 +2280,8 @@ octnet_init_failure: } /** - * \brief Device initialization for each Octeon device that is probed - * @param octeon_dev octeon device + * octeon_device_init - Device initialization for each Octeon device that is probed + * @oct: octeon device */ static int octeon_device_init(struct octeon_device *oct) { @@ -2352,8 +2367,8 @@ static int octeon_device_init(struct octeon_device *oct) } atomic_set(&oct->status, OCT_DEV_MSIX_ALLOC_VECTOR_DONE); - dev_info(&oct->pci_dev->dev, "OCTEON_CN23XX VF Version: %s, %d ioqs\n", - LIQUIDIO_VERSION, oct->sriov_info.rings_per_vf); + dev_info(&oct->pci_dev->dev, "OCTEON_CN23XX VF: %d ioqs\n", + oct->sriov_info.rings_per_vf); /* Setup the interrupt handler and record the INT SUM register address*/ if (octeon_setup_interrupt(oct, oct->sriov_info.rings_per_vf)) |