Loading drivers/net/ibmveth.c +172 −145 Original line number Diff line number Diff line /**************************************************************************/ /* */ /* IBM eServer i/pSeries Virtual Ethernet Device Driver */ /* Copyright (C) 2003 IBM Corp. */ /* Originally written by Dave Larson (larson1@us.ibm.com) */ /* Maintained by Santiago Leon (santil@us.ibm.com) */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /* This program is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ /* along with this program; if not, write to the Free Software */ /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 */ /* USA */ /* */ /* This module contains the implementation of a virtual ethernet device */ /* for use with IBM i/pSeries LPAR Linux. It utilizes the logical LAN */ /* option of the RS/6000 Platform Architechture to interface with virtual */ /* ethernet NICs that are presented to the partition by the hypervisor. */ /* */ /**************************************************************************/ /* * IBM eServer i/pSeries Virtual Ethernet Device Driver * Copyright (C) 2003 IBM Corp. * Originally written by Dave Larson (larson1@us.ibm.com) * Maintained by Santiago Leon (santil@us.ibm.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA * * This module contains the implementation of a virtual ethernet device * for use with IBM i/pSeries LPAR Linux. It utilizes the logical LAN * option of the RS/6000 Platform Architechture to interface with virtual * ethernet NICs that are presented to the partition by the hypervisor. */ #include <linux/module.h> #include <linux/moduleparam.h> Loading Loading @@ -75,7 +73,8 @@ static struct kobj_type ktype_veth_pool; static const char ibmveth_driver_name[] = "ibmveth"; static const char ibmveth_driver_string[] = "IBM i/pSeries Virtual Ethernet Driver"; static const char ibmveth_driver_string[] = "IBM i/pSeries Virtual Ethernet " "Driver"; #define ibmveth_driver_version "1.03" MODULE_AUTHOR("Santiago Leon <santil@us.ibm.com>"); Loading Loading @@ -108,8 +107,10 @@ struct ibmveth_stat { struct ibmveth_stat ibmveth_stats[] = { { "replenish_task_cycles", IBMVETH_STAT_OFF(replenish_task_cycles) }, { "replenish_no_mem", IBMVETH_STAT_OFF(replenish_no_mem) }, { "replenish_add_buff_failure", IBMVETH_STAT_OFF(replenish_add_buff_failure) }, { "replenish_add_buff_success", IBMVETH_STAT_OFF(replenish_add_buff_success) }, { "replenish_add_buff_failure", IBMVETH_STAT_OFF(replenish_add_buff_failure) }, { "replenish_add_buff_success", IBMVETH_STAT_OFF(replenish_add_buff_success) }, { "rx_invalid_buffer", IBMVETH_STAT_OFF(rx_invalid_buffer) }, { "rx_no_buffer", IBMVETH_STAT_OFF(rx_no_buffer) }, { "tx_map_failed", IBMVETH_STAT_OFF(tx_map_failed) }, Loading @@ -126,36 +127,39 @@ static inline u32 ibmveth_rxq_flags(struct ibmveth_adapter *adapter) static inline int ibmveth_rxq_toggle(struct ibmveth_adapter *adapter) { return (ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_TOGGLE) >> IBMVETH_RXQ_TOGGLE_SHIFT; return (ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_TOGGLE) >> IBMVETH_RXQ_TOGGLE_SHIFT; } static inline int ibmveth_rxq_pending_buffer(struct ibmveth_adapter *adapter) { return (ibmveth_rxq_toggle(adapter) == adapter->rx_queue.toggle); return ibmveth_rxq_toggle(adapter) == adapter->rx_queue.toggle; } static inline int ibmveth_rxq_buffer_valid(struct ibmveth_adapter *adapter) { return (ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_VALID); return ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_VALID; } static inline int ibmveth_rxq_frame_offset(struct ibmveth_adapter *adapter) { return (ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_OFF_MASK); return ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_OFF_MASK; } static inline int ibmveth_rxq_frame_length(struct ibmveth_adapter *adapter) { return (adapter->rx_queue.queue_addr[adapter->rx_queue.index].length); return adapter->rx_queue.queue_addr[adapter->rx_queue.index].length; } static inline int ibmveth_rxq_csum_good(struct ibmveth_adapter *adapter) { return (ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_CSUM_GOOD); return ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_CSUM_GOOD; } /* setup the initial settings for a buffer pool */ static void ibmveth_init_buffer_pool(struct ibmveth_buff_pool *pool, u32 pool_index, u32 pool_size, u32 buff_size, u32 pool_active) static void ibmveth_init_buffer_pool(struct ibmveth_buff_pool *pool, u32 pool_index, u32 pool_size, u32 buff_size, u32 pool_active) { pool->size = pool_size; pool->index = pool_index; Loading @@ -171,9 +175,8 @@ static int ibmveth_alloc_buffer_pool(struct ibmveth_buff_pool *pool) pool->free_map = kmalloc(sizeof(u16) * pool->size, GFP_KERNEL); if(!pool->free_map) { if (!pool->free_map) return -1; } pool->dma_addr = kmalloc(sizeof(dma_addr_t) * pool->size, GFP_KERNEL); if (!pool->dma_addr) { Loading @@ -195,9 +198,8 @@ static int ibmveth_alloc_buffer_pool(struct ibmveth_buff_pool *pool) memset(pool->dma_addr, 0, sizeof(dma_addr_t) * pool->size); for(i = 0; i < pool->size; ++i) { for (i = 0; i < pool->size; ++i) pool->free_map[i] = i; } atomic_set(&pool->available, 0); pool->producer_index = 0; Loading @@ -217,7 +219,8 @@ static inline void ibmveth_flush_buffer(void *addr, unsigned long length) /* replenish the buffers for a pool. note that we don't need to * skb_reserve these since they are used for incoming... */ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struct ibmveth_buff_pool *pool) static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struct ibmveth_buff_pool *pool) { u32 i; u32 count = pool->size - atomic_read(&pool->available); Loading Loading @@ -273,11 +276,12 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struc IBMVETH_BUFF_OH); ibmveth_flush_buffer(skb->data, len); } lpar_rc = h_add_logical_lan_buffer(adapter->vdev->unit_address, desc.desc); lpar_rc = h_add_logical_lan_buffer(adapter->vdev->unit_address, desc.desc); if (lpar_rc != H_SUCCESS) if (lpar_rc != H_SUCCESS) { goto failure; else { } else { buffers_added++; adapter->replenish_add_buff_success++; } Loading Loading @@ -320,11 +324,13 @@ static void ibmveth_replenish_task(struct ibmveth_adapter *adapter) ibmveth_replenish_buffer_pool(adapter, pool); } adapter->rx_no_buffer = *(u64*)(((char*)adapter->buffer_list_addr) + 4096 - 8); adapter->rx_no_buffer = *(u64 *)(((char*)adapter->buffer_list_addr) + 4096 - 8); } /* empty and free ana buffer pool - also used to do cleanup in error paths */ static void ibmveth_free_buffer_pool(struct ibmveth_adapter *adapter, struct ibmveth_buff_pool *pool) static void ibmveth_free_buffer_pool(struct ibmveth_adapter *adapter, struct ibmveth_buff_pool *pool) { int i; Loading Loading @@ -357,7 +363,8 @@ static void ibmveth_free_buffer_pool(struct ibmveth_adapter *adapter, struct ibm } /* remove a buffer from a pool */ static void ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter, u64 correlator) static void ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter, u64 correlator) { unsigned int pool = correlator >> 32; unsigned int index = correlator & 0xffffffffUL; Loading Loading @@ -510,9 +517,11 @@ static int ibmveth_register_logical_lan(struct ibmveth_adapter *adapter, { int rc, try_again = 1; /* After a kexec the adapter will still be open, so our attempt to /* * After a kexec the adapter will still be open, so our attempt to * open it will fail. So if we get a failure we free the adapter and * try again, but only once. */ * try again, but only once. */ retry: rc = h_register_logical_lan(adapter->vdev->unit_address, adapter->buffer_list_dma, rxq_desc.desc, Loading Loading @@ -559,8 +568,10 @@ static int ibmveth_open(struct net_device *netdev) return -ENOMEM; } adapter->rx_queue.queue_len = sizeof(struct ibmveth_rx_q_entry) * rxq_entries; adapter->rx_queue.queue_addr = kmalloc(adapter->rx_queue.queue_len, GFP_KERNEL); adapter->rx_queue.queue_len = sizeof(struct ibmveth_rx_q_entry) * rxq_entries; adapter->rx_queue.queue_addr = kmalloc(adapter->rx_queue.queue_len, GFP_KERNEL); if (!adapter->rx_queue.queue_addr) { netdev_err(netdev, "unable to allocate rx queue pages\n"); Loading Loading @@ -596,7 +607,8 @@ static int ibmveth_open(struct net_device *netdev) memcpy(&mac_address, netdev->dev_addr, netdev->addr_len); mac_address = mac_address >> 16; rxq_desc.fields.flags_len = IBMVETH_BUF_VALID | adapter->rx_queue.queue_len; rxq_desc.fields.flags_len = IBMVETH_BUF_VALID | adapter->rx_queue.queue_len; rxq_desc.fields.address = adapter->rx_queue.queue_dma; netdev_dbg(netdev, "buffer list @ 0x%p\n", adapter->buffer_list_addr); Loading Loading @@ -634,7 +646,9 @@ static int ibmveth_open(struct net_device *netdev) } netdev_dbg(netdev, "registering irq 0x%x\n", netdev->irq); if((rc = request_irq(netdev->irq, ibmveth_interrupt, 0, netdev->name, netdev)) != 0) { rc = request_irq(netdev->irq, ibmveth_interrupt, 0, netdev->name, netdev); if (rc != 0) { netdev_err(netdev, "unable to request irq 0x%x, rc %d\n", netdev->irq, rc); do { Loading Loading @@ -692,15 +706,15 @@ static int ibmveth_close(struct net_device *netdev) lpar_rc = h_free_logical_lan(adapter->vdev->unit_address); } while (H_IS_LONG_BUSY(lpar_rc) || (lpar_rc == H_BUSY)); if(lpar_rc != H_SUCCESS) { if (lpar_rc != H_SUCCESS) { netdev_err(netdev, "h_free_logical_lan failed with %lx, " "continuing with close\n", lpar_rc); } free_irq(netdev->irq, netdev); adapter->rx_no_buffer = *(u64*)(((char*)adapter->buffer_list_addr) + 4096 - 8); adapter->rx_no_buffer = *(u64 *)(((char *)adapter->buffer_list_addr) + 4096 - 8); ibmveth_cleanup(adapter); Loading @@ -709,9 +723,12 @@ static int ibmveth_close(struct net_device *netdev) return 0; } static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) { cmd->supported = (SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg | SUPPORTED_FIBRE); cmd->advertising = (ADVERTISED_1000baseT_Full | ADVERTISED_Autoneg | ADVERTISED_FIBRE); static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) { cmd->supported = (SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg | SUPPORTED_FIBRE); cmd->advertising = (ADVERTISED_1000baseT_Full | ADVERTISED_Autoneg | ADVERTISED_FIBRE); cmd->speed = SPEED_1000; cmd->duplex = DUPLEX_FULL; cmd->port = PORT_FIBRE; Loading @@ -723,12 +740,16 @@ static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) return 0; } static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info) { static void netdev_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { strncpy(info->driver, ibmveth_driver_name, sizeof(info->driver) - 1); strncpy(info->version, ibmveth_driver_version, sizeof(info->version) - 1); strncpy(info->version, ibmveth_driver_version, sizeof(info->version) - 1); } static u32 netdev_get_link(struct net_device *dev) { static u32 netdev_get_link(struct net_device *dev) { return 1; } Loading @@ -736,15 +757,16 @@ static void ibmveth_set_rx_csum_flags(struct net_device *dev, u32 data) { struct ibmveth_adapter *adapter = netdev_priv(dev); if (data) if (data) { adapter->rx_csum = 1; else { } else { /* * Since the ibmveth firmware interface does not have the concept of * separate tx/rx checksum offload enable, if rx checksum is disabled * we also have to disable tx checksum offload. Once we disable rx * checksum offload, we are no longer allowed to send tx buffers that * are not properly checksummed. * Since the ibmveth firmware interface does not have the * concept of separate tx/rx checksum offload enable, if rx * checksum is disabled we also have to disable tx checksum * offload. Once we disable rx checksum offload, we are no * longer allowed to send tx buffers that are not properly * checksummed. */ adapter->rx_csum = 0; dev->features &= ~NETIF_F_IP_CSUM; Loading Loading @@ -811,8 +833,9 @@ static int ibmveth_set_csum_offload(struct net_device *dev, u32 data, ret = h_illan_attributes(adapter->vdev->unit_address, set_attr, clr_attr, &ret_attr); } else } else { adapter->fw_ipv4_csum_support = data; } ret6 = h_illan_attributes(adapter->vdev->unit_address, clr_attr6, set_attr6, &ret_attr); Loading Loading @@ -866,7 +889,8 @@ static int ibmveth_set_tx_csum(struct net_device *dev, u32 data) return 0; if (data && !adapter->rx_csum) rc = ibmveth_set_csum_offload(dev, data, ibmveth_set_tx_csum_flags); rc = ibmveth_set_csum_offload(dev, data, ibmveth_set_tx_csum_flags); else ibmveth_set_tx_csum_flags(dev, data); Loading Loading @@ -1091,7 +1115,8 @@ static netdev_tx_t ibmveth_start_xmit(struct sk_buff *skb, static int ibmveth_poll(struct napi_struct *napi, int budget) { struct ibmveth_adapter *adapter = container_of(napi, struct ibmveth_adapter, napi); struct ibmveth_adapter *adapter = container_of(napi, struct ibmveth_adapter, napi); struct net_device *netdev = adapter->netdev; int frames_processed = 0; unsigned long lpar_rc; Loading Loading @@ -1216,7 +1241,7 @@ static void ibmveth_set_multicast_list(struct net_device *netdev) } /* add the addresses to the filter table */ netdev_for_each_mc_addr(ha, netdev) { // add the multicast address to the filter table /* add the multicast address to the filter table */ unsigned long mcast_addr = 0; memcpy(((char *)&mcast_addr)+2, ha->addr, 6); lpar_rc = h_multicast_ctrl(adapter->vdev->unit_address, Loading Loading @@ -1351,21 +1376,20 @@ static const struct net_device_ops ibmveth_netdev_ops = { #endif }; static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id) static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id) { int rc, i; struct net_device *netdev; struct ibmveth_adapter *adapter; unsigned char *mac_addr_p; unsigned int *mcastFilterSize_p; dev_dbg(&dev->dev, "entering ibmveth_probe for UA 0x%x\n", dev->unit_address); mac_addr_p = (unsigned char *) vio_get_attribute(dev, VETH_MAC_ADDR, NULL); mac_addr_p = (unsigned char *)vio_get_attribute(dev, VETH_MAC_ADDR, NULL); if (!mac_addr_p) { dev_err(&dev->dev, "Can't find VETH_MAC_ADDR attribute\n"); return 0; Loading Loading @@ -1394,14 +1418,14 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_ netif_napi_add(netdev, &adapter->napi, ibmveth_poll, 16); /* Some older boxes running PHYP non-natively have an OF that returns a 8-byte local-mac-address field (and the first 2 bytes have to be ignored) while newer boxes' OF return a 6-byte field. Note that IEEE 1275 specifies that local-mac-address must be a 6-byte field. The RPA doc specifies that the first byte must be 10b, so we'll just look for it to solve this 8 vs. 6 byte field issue */ /* * Some older boxes running PHYP non-natively have an OF that returns * a 8-byte local-mac-address field (and the first 2 bytes have to be * ignored) while newer boxes' OF return a 6-byte field. Note that * IEEE 1275 specifies that local-mac-address must be a 6-byte field. * The RPA doc specifies that the first byte must be 10b, so we'll * just look for it to solve this 8 vs. 6 byte field issue */ if ((*mac_addr_p & 0x3) != 0x02) mac_addr_p += 2; Loading Loading @@ -1515,8 +1539,9 @@ const char * buf, size_t count) adapter->pool_config = 0; if ((rc = ibmveth_open(netdev))) return rc; } else } else { pool->active = 1; } } else if (!value && pool->active) { int mtu = netdev->mtu + IBMVETH_BUFF_OH; int i; Loading Loading @@ -1547,9 +1572,9 @@ const char * buf, size_t count) pool->active = 0; } } else if (attr == &veth_num_attr) { if (value <= 0 || value > IBMVETH_MAX_POOL_COUNT) if (value <= 0 || value > IBMVETH_MAX_POOL_COUNT) { return -EINVAL; else { } else { if (netif_running(netdev)) { adapter->pool_config = 1; ibmveth_close(netdev); Loading @@ -1557,13 +1582,14 @@ const char * buf, size_t count) pool->size = value; if ((rc = ibmveth_open(netdev))) return rc; } else } else { pool->size = value; } } } else if (attr == &veth_size_attr) { if (value <= IBMVETH_BUFF_OH || value > IBMVETH_MAX_BUF_SIZE) if (value <= IBMVETH_BUFF_OH || value > IBMVETH_MAX_BUF_SIZE) { return -EINVAL; else { } else { if (netif_running(netdev)) { adapter->pool_config = 1; ibmveth_close(netdev); Loading @@ -1571,10 +1597,11 @@ const char * buf, size_t count) pool->buff_size = value; if ((rc = ibmveth_open(netdev))) return rc; } else } else { pool->buff_size = value; } } } /* kick the interrupt handler to allocate/deallocate pools */ ibmveth_interrupt(netdev->irq, netdev); Loading Loading
drivers/net/ibmveth.c +172 −145 Original line number Diff line number Diff line /**************************************************************************/ /* */ /* IBM eServer i/pSeries Virtual Ethernet Device Driver */ /* Copyright (C) 2003 IBM Corp. */ /* Originally written by Dave Larson (larson1@us.ibm.com) */ /* Maintained by Santiago Leon (santil@us.ibm.com) */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /* This program is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ /* along with this program; if not, write to the Free Software */ /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 */ /* USA */ /* */ /* This module contains the implementation of a virtual ethernet device */ /* for use with IBM i/pSeries LPAR Linux. It utilizes the logical LAN */ /* option of the RS/6000 Platform Architechture to interface with virtual */ /* ethernet NICs that are presented to the partition by the hypervisor. */ /* */ /**************************************************************************/ /* * IBM eServer i/pSeries Virtual Ethernet Device Driver * Copyright (C) 2003 IBM Corp. * Originally written by Dave Larson (larson1@us.ibm.com) * Maintained by Santiago Leon (santil@us.ibm.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA * * This module contains the implementation of a virtual ethernet device * for use with IBM i/pSeries LPAR Linux. It utilizes the logical LAN * option of the RS/6000 Platform Architechture to interface with virtual * ethernet NICs that are presented to the partition by the hypervisor. */ #include <linux/module.h> #include <linux/moduleparam.h> Loading Loading @@ -75,7 +73,8 @@ static struct kobj_type ktype_veth_pool; static const char ibmveth_driver_name[] = "ibmveth"; static const char ibmveth_driver_string[] = "IBM i/pSeries Virtual Ethernet Driver"; static const char ibmveth_driver_string[] = "IBM i/pSeries Virtual Ethernet " "Driver"; #define ibmveth_driver_version "1.03" MODULE_AUTHOR("Santiago Leon <santil@us.ibm.com>"); Loading Loading @@ -108,8 +107,10 @@ struct ibmveth_stat { struct ibmveth_stat ibmveth_stats[] = { { "replenish_task_cycles", IBMVETH_STAT_OFF(replenish_task_cycles) }, { "replenish_no_mem", IBMVETH_STAT_OFF(replenish_no_mem) }, { "replenish_add_buff_failure", IBMVETH_STAT_OFF(replenish_add_buff_failure) }, { "replenish_add_buff_success", IBMVETH_STAT_OFF(replenish_add_buff_success) }, { "replenish_add_buff_failure", IBMVETH_STAT_OFF(replenish_add_buff_failure) }, { "replenish_add_buff_success", IBMVETH_STAT_OFF(replenish_add_buff_success) }, { "rx_invalid_buffer", IBMVETH_STAT_OFF(rx_invalid_buffer) }, { "rx_no_buffer", IBMVETH_STAT_OFF(rx_no_buffer) }, { "tx_map_failed", IBMVETH_STAT_OFF(tx_map_failed) }, Loading @@ -126,36 +127,39 @@ static inline u32 ibmveth_rxq_flags(struct ibmveth_adapter *adapter) static inline int ibmveth_rxq_toggle(struct ibmveth_adapter *adapter) { return (ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_TOGGLE) >> IBMVETH_RXQ_TOGGLE_SHIFT; return (ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_TOGGLE) >> IBMVETH_RXQ_TOGGLE_SHIFT; } static inline int ibmveth_rxq_pending_buffer(struct ibmveth_adapter *adapter) { return (ibmveth_rxq_toggle(adapter) == adapter->rx_queue.toggle); return ibmveth_rxq_toggle(adapter) == adapter->rx_queue.toggle; } static inline int ibmveth_rxq_buffer_valid(struct ibmveth_adapter *adapter) { return (ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_VALID); return ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_VALID; } static inline int ibmveth_rxq_frame_offset(struct ibmveth_adapter *adapter) { return (ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_OFF_MASK); return ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_OFF_MASK; } static inline int ibmveth_rxq_frame_length(struct ibmveth_adapter *adapter) { return (adapter->rx_queue.queue_addr[adapter->rx_queue.index].length); return adapter->rx_queue.queue_addr[adapter->rx_queue.index].length; } static inline int ibmveth_rxq_csum_good(struct ibmveth_adapter *adapter) { return (ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_CSUM_GOOD); return ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_CSUM_GOOD; } /* setup the initial settings for a buffer pool */ static void ibmveth_init_buffer_pool(struct ibmveth_buff_pool *pool, u32 pool_index, u32 pool_size, u32 buff_size, u32 pool_active) static void ibmveth_init_buffer_pool(struct ibmveth_buff_pool *pool, u32 pool_index, u32 pool_size, u32 buff_size, u32 pool_active) { pool->size = pool_size; pool->index = pool_index; Loading @@ -171,9 +175,8 @@ static int ibmveth_alloc_buffer_pool(struct ibmveth_buff_pool *pool) pool->free_map = kmalloc(sizeof(u16) * pool->size, GFP_KERNEL); if(!pool->free_map) { if (!pool->free_map) return -1; } pool->dma_addr = kmalloc(sizeof(dma_addr_t) * pool->size, GFP_KERNEL); if (!pool->dma_addr) { Loading @@ -195,9 +198,8 @@ static int ibmveth_alloc_buffer_pool(struct ibmveth_buff_pool *pool) memset(pool->dma_addr, 0, sizeof(dma_addr_t) * pool->size); for(i = 0; i < pool->size; ++i) { for (i = 0; i < pool->size; ++i) pool->free_map[i] = i; } atomic_set(&pool->available, 0); pool->producer_index = 0; Loading @@ -217,7 +219,8 @@ static inline void ibmveth_flush_buffer(void *addr, unsigned long length) /* replenish the buffers for a pool. note that we don't need to * skb_reserve these since they are used for incoming... */ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struct ibmveth_buff_pool *pool) static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struct ibmveth_buff_pool *pool) { u32 i; u32 count = pool->size - atomic_read(&pool->available); Loading Loading @@ -273,11 +276,12 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struc IBMVETH_BUFF_OH); ibmveth_flush_buffer(skb->data, len); } lpar_rc = h_add_logical_lan_buffer(adapter->vdev->unit_address, desc.desc); lpar_rc = h_add_logical_lan_buffer(adapter->vdev->unit_address, desc.desc); if (lpar_rc != H_SUCCESS) if (lpar_rc != H_SUCCESS) { goto failure; else { } else { buffers_added++; adapter->replenish_add_buff_success++; } Loading Loading @@ -320,11 +324,13 @@ static void ibmveth_replenish_task(struct ibmveth_adapter *adapter) ibmveth_replenish_buffer_pool(adapter, pool); } adapter->rx_no_buffer = *(u64*)(((char*)adapter->buffer_list_addr) + 4096 - 8); adapter->rx_no_buffer = *(u64 *)(((char*)adapter->buffer_list_addr) + 4096 - 8); } /* empty and free ana buffer pool - also used to do cleanup in error paths */ static void ibmveth_free_buffer_pool(struct ibmveth_adapter *adapter, struct ibmveth_buff_pool *pool) static void ibmveth_free_buffer_pool(struct ibmveth_adapter *adapter, struct ibmveth_buff_pool *pool) { int i; Loading Loading @@ -357,7 +363,8 @@ static void ibmveth_free_buffer_pool(struct ibmveth_adapter *adapter, struct ibm } /* remove a buffer from a pool */ static void ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter, u64 correlator) static void ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter, u64 correlator) { unsigned int pool = correlator >> 32; unsigned int index = correlator & 0xffffffffUL; Loading Loading @@ -510,9 +517,11 @@ static int ibmveth_register_logical_lan(struct ibmveth_adapter *adapter, { int rc, try_again = 1; /* After a kexec the adapter will still be open, so our attempt to /* * After a kexec the adapter will still be open, so our attempt to * open it will fail. So if we get a failure we free the adapter and * try again, but only once. */ * try again, but only once. */ retry: rc = h_register_logical_lan(adapter->vdev->unit_address, adapter->buffer_list_dma, rxq_desc.desc, Loading Loading @@ -559,8 +568,10 @@ static int ibmveth_open(struct net_device *netdev) return -ENOMEM; } adapter->rx_queue.queue_len = sizeof(struct ibmveth_rx_q_entry) * rxq_entries; adapter->rx_queue.queue_addr = kmalloc(adapter->rx_queue.queue_len, GFP_KERNEL); adapter->rx_queue.queue_len = sizeof(struct ibmveth_rx_q_entry) * rxq_entries; adapter->rx_queue.queue_addr = kmalloc(adapter->rx_queue.queue_len, GFP_KERNEL); if (!adapter->rx_queue.queue_addr) { netdev_err(netdev, "unable to allocate rx queue pages\n"); Loading Loading @@ -596,7 +607,8 @@ static int ibmveth_open(struct net_device *netdev) memcpy(&mac_address, netdev->dev_addr, netdev->addr_len); mac_address = mac_address >> 16; rxq_desc.fields.flags_len = IBMVETH_BUF_VALID | adapter->rx_queue.queue_len; rxq_desc.fields.flags_len = IBMVETH_BUF_VALID | adapter->rx_queue.queue_len; rxq_desc.fields.address = adapter->rx_queue.queue_dma; netdev_dbg(netdev, "buffer list @ 0x%p\n", adapter->buffer_list_addr); Loading Loading @@ -634,7 +646,9 @@ static int ibmveth_open(struct net_device *netdev) } netdev_dbg(netdev, "registering irq 0x%x\n", netdev->irq); if((rc = request_irq(netdev->irq, ibmveth_interrupt, 0, netdev->name, netdev)) != 0) { rc = request_irq(netdev->irq, ibmveth_interrupt, 0, netdev->name, netdev); if (rc != 0) { netdev_err(netdev, "unable to request irq 0x%x, rc %d\n", netdev->irq, rc); do { Loading Loading @@ -692,15 +706,15 @@ static int ibmveth_close(struct net_device *netdev) lpar_rc = h_free_logical_lan(adapter->vdev->unit_address); } while (H_IS_LONG_BUSY(lpar_rc) || (lpar_rc == H_BUSY)); if(lpar_rc != H_SUCCESS) { if (lpar_rc != H_SUCCESS) { netdev_err(netdev, "h_free_logical_lan failed with %lx, " "continuing with close\n", lpar_rc); } free_irq(netdev->irq, netdev); adapter->rx_no_buffer = *(u64*)(((char*)adapter->buffer_list_addr) + 4096 - 8); adapter->rx_no_buffer = *(u64 *)(((char *)adapter->buffer_list_addr) + 4096 - 8); ibmveth_cleanup(adapter); Loading @@ -709,9 +723,12 @@ static int ibmveth_close(struct net_device *netdev) return 0; } static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) { cmd->supported = (SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg | SUPPORTED_FIBRE); cmd->advertising = (ADVERTISED_1000baseT_Full | ADVERTISED_Autoneg | ADVERTISED_FIBRE); static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) { cmd->supported = (SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg | SUPPORTED_FIBRE); cmd->advertising = (ADVERTISED_1000baseT_Full | ADVERTISED_Autoneg | ADVERTISED_FIBRE); cmd->speed = SPEED_1000; cmd->duplex = DUPLEX_FULL; cmd->port = PORT_FIBRE; Loading @@ -723,12 +740,16 @@ static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) return 0; } static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info) { static void netdev_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { strncpy(info->driver, ibmveth_driver_name, sizeof(info->driver) - 1); strncpy(info->version, ibmveth_driver_version, sizeof(info->version) - 1); strncpy(info->version, ibmveth_driver_version, sizeof(info->version) - 1); } static u32 netdev_get_link(struct net_device *dev) { static u32 netdev_get_link(struct net_device *dev) { return 1; } Loading @@ -736,15 +757,16 @@ static void ibmveth_set_rx_csum_flags(struct net_device *dev, u32 data) { struct ibmveth_adapter *adapter = netdev_priv(dev); if (data) if (data) { adapter->rx_csum = 1; else { } else { /* * Since the ibmveth firmware interface does not have the concept of * separate tx/rx checksum offload enable, if rx checksum is disabled * we also have to disable tx checksum offload. Once we disable rx * checksum offload, we are no longer allowed to send tx buffers that * are not properly checksummed. * Since the ibmveth firmware interface does not have the * concept of separate tx/rx checksum offload enable, if rx * checksum is disabled we also have to disable tx checksum * offload. Once we disable rx checksum offload, we are no * longer allowed to send tx buffers that are not properly * checksummed. */ adapter->rx_csum = 0; dev->features &= ~NETIF_F_IP_CSUM; Loading Loading @@ -811,8 +833,9 @@ static int ibmveth_set_csum_offload(struct net_device *dev, u32 data, ret = h_illan_attributes(adapter->vdev->unit_address, set_attr, clr_attr, &ret_attr); } else } else { adapter->fw_ipv4_csum_support = data; } ret6 = h_illan_attributes(adapter->vdev->unit_address, clr_attr6, set_attr6, &ret_attr); Loading Loading @@ -866,7 +889,8 @@ static int ibmveth_set_tx_csum(struct net_device *dev, u32 data) return 0; if (data && !adapter->rx_csum) rc = ibmveth_set_csum_offload(dev, data, ibmveth_set_tx_csum_flags); rc = ibmveth_set_csum_offload(dev, data, ibmveth_set_tx_csum_flags); else ibmveth_set_tx_csum_flags(dev, data); Loading Loading @@ -1091,7 +1115,8 @@ static netdev_tx_t ibmveth_start_xmit(struct sk_buff *skb, static int ibmveth_poll(struct napi_struct *napi, int budget) { struct ibmveth_adapter *adapter = container_of(napi, struct ibmveth_adapter, napi); struct ibmveth_adapter *adapter = container_of(napi, struct ibmveth_adapter, napi); struct net_device *netdev = adapter->netdev; int frames_processed = 0; unsigned long lpar_rc; Loading Loading @@ -1216,7 +1241,7 @@ static void ibmveth_set_multicast_list(struct net_device *netdev) } /* add the addresses to the filter table */ netdev_for_each_mc_addr(ha, netdev) { // add the multicast address to the filter table /* add the multicast address to the filter table */ unsigned long mcast_addr = 0; memcpy(((char *)&mcast_addr)+2, ha->addr, 6); lpar_rc = h_multicast_ctrl(adapter->vdev->unit_address, Loading Loading @@ -1351,21 +1376,20 @@ static const struct net_device_ops ibmveth_netdev_ops = { #endif }; static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id) static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id) { int rc, i; struct net_device *netdev; struct ibmveth_adapter *adapter; unsigned char *mac_addr_p; unsigned int *mcastFilterSize_p; dev_dbg(&dev->dev, "entering ibmveth_probe for UA 0x%x\n", dev->unit_address); mac_addr_p = (unsigned char *) vio_get_attribute(dev, VETH_MAC_ADDR, NULL); mac_addr_p = (unsigned char *)vio_get_attribute(dev, VETH_MAC_ADDR, NULL); if (!mac_addr_p) { dev_err(&dev->dev, "Can't find VETH_MAC_ADDR attribute\n"); return 0; Loading Loading @@ -1394,14 +1418,14 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_ netif_napi_add(netdev, &adapter->napi, ibmveth_poll, 16); /* Some older boxes running PHYP non-natively have an OF that returns a 8-byte local-mac-address field (and the first 2 bytes have to be ignored) while newer boxes' OF return a 6-byte field. Note that IEEE 1275 specifies that local-mac-address must be a 6-byte field. The RPA doc specifies that the first byte must be 10b, so we'll just look for it to solve this 8 vs. 6 byte field issue */ /* * Some older boxes running PHYP non-natively have an OF that returns * a 8-byte local-mac-address field (and the first 2 bytes have to be * ignored) while newer boxes' OF return a 6-byte field. Note that * IEEE 1275 specifies that local-mac-address must be a 6-byte field. * The RPA doc specifies that the first byte must be 10b, so we'll * just look for it to solve this 8 vs. 6 byte field issue */ if ((*mac_addr_p & 0x3) != 0x02) mac_addr_p += 2; Loading Loading @@ -1515,8 +1539,9 @@ const char * buf, size_t count) adapter->pool_config = 0; if ((rc = ibmveth_open(netdev))) return rc; } else } else { pool->active = 1; } } else if (!value && pool->active) { int mtu = netdev->mtu + IBMVETH_BUFF_OH; int i; Loading Loading @@ -1547,9 +1572,9 @@ const char * buf, size_t count) pool->active = 0; } } else if (attr == &veth_num_attr) { if (value <= 0 || value > IBMVETH_MAX_POOL_COUNT) if (value <= 0 || value > IBMVETH_MAX_POOL_COUNT) { return -EINVAL; else { } else { if (netif_running(netdev)) { adapter->pool_config = 1; ibmveth_close(netdev); Loading @@ -1557,13 +1582,14 @@ const char * buf, size_t count) pool->size = value; if ((rc = ibmveth_open(netdev))) return rc; } else } else { pool->size = value; } } } else if (attr == &veth_size_attr) { if (value <= IBMVETH_BUFF_OH || value > IBMVETH_MAX_BUF_SIZE) if (value <= IBMVETH_BUFF_OH || value > IBMVETH_MAX_BUF_SIZE) { return -EINVAL; else { } else { if (netif_running(netdev)) { adapter->pool_config = 1; ibmveth_close(netdev); Loading @@ -1571,10 +1597,11 @@ const char * buf, size_t count) pool->buff_size = value; if ((rc = ibmveth_open(netdev))) return rc; } else } else { pool->buff_size = value; } } } /* kick the interrupt handler to allocate/deallocate pools */ ibmveth_interrupt(netdev->irq, netdev); Loading