729
729
sizeof(info->version) - 1);
732
static void ibmveth_set_rx_csum_flags(struct net_device *dev, u32 data)
734
struct ibmveth_adapter *adapter = netdev_priv(dev);
737
adapter->rx_csum = 1;
740
* Since the ibmveth firmware interface does not have the
741
* concept of separate tx/rx checksum offload enable, if rx
742
* checksum is disabled we also have to disable tx checksum
743
* offload. Once we disable rx checksum offload, we are no
744
* longer allowed to send tx buffers that are not properly
747
adapter->rx_csum = 0;
748
dev->features &= ~NETIF_F_IP_CSUM;
749
dev->features &= ~NETIF_F_IPV6_CSUM;
753
static void ibmveth_set_tx_csum_flags(struct net_device *dev, u32 data)
755
struct ibmveth_adapter *adapter = netdev_priv(dev);
758
if (adapter->fw_ipv4_csum_support)
759
dev->features |= NETIF_F_IP_CSUM;
760
if (adapter->fw_ipv6_csum_support)
761
dev->features |= NETIF_F_IPV6_CSUM;
762
adapter->rx_csum = 1;
764
dev->features &= ~NETIF_F_IP_CSUM;
765
dev->features &= ~NETIF_F_IPV6_CSUM;
769
static int ibmveth_set_csum_offload(struct net_device *dev, u32 data,
770
void (*done) (struct net_device *, u32))
732
static u32 ibmveth_fix_features(struct net_device *dev, u32 features)
735
* Since the ibmveth firmware interface does not have the
736
* concept of separate tx/rx checksum offload enable, if rx
737
* checksum is disabled we also have to disable tx checksum
738
* offload. Once we disable rx checksum offload, we are no
739
* longer allowed to send tx buffers that are not properly
743
if (!(features & NETIF_F_RXCSUM))
744
features &= ~NETIF_F_ALL_CSUM;
749
static int ibmveth_set_csum_offload(struct net_device *dev, u32 data)
772
751
struct ibmveth_adapter *adapter = netdev_priv(dev);
773
752
unsigned long set_attr, clr_attr, ret_attr;
844
823
return rc1 ? rc1 : rc2;
847
static int ibmveth_set_rx_csum(struct net_device *dev, u32 data)
849
struct ibmveth_adapter *adapter = netdev_priv(dev);
851
if ((data && adapter->rx_csum) || (!data && !adapter->rx_csum))
854
return ibmveth_set_csum_offload(dev, data, ibmveth_set_rx_csum_flags);
857
static int ibmveth_set_tx_csum(struct net_device *dev, u32 data)
859
struct ibmveth_adapter *adapter = netdev_priv(dev);
862
if (data && (dev->features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)))
864
if (!data && !(dev->features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)))
867
if (data && !adapter->rx_csum)
868
rc = ibmveth_set_csum_offload(dev, data,
869
ibmveth_set_tx_csum_flags);
871
ibmveth_set_tx_csum_flags(dev, data);
826
static int ibmveth_set_features(struct net_device *dev, u32 features)
828
struct ibmveth_adapter *adapter = netdev_priv(dev);
829
int rx_csum = !!(features & NETIF_F_RXCSUM);
832
if (rx_csum == adapter->rx_csum)
835
rc = ibmveth_set_csum_offload(dev, rx_csum);
836
if (rc && !adapter->rx_csum)
837
dev->features = features & ~(NETIF_F_ALL_CSUM | NETIF_F_RXCSUM);
876
static u32 ibmveth_get_rx_csum(struct net_device *dev)
878
struct ibmveth_adapter *adapter = netdev_priv(dev);
879
return adapter->rx_csum;
882
842
static void ibmveth_get_strings(struct net_device *dev, u32 stringset, u8 *data)
914
874
.get_drvinfo = netdev_get_drvinfo,
915
875
.get_settings = netdev_get_settings,
916
876
.get_link = ethtool_op_get_link,
917
.set_tx_csum = ibmveth_set_tx_csum,
918
.get_rx_csum = ibmveth_get_rx_csum,
919
.set_rx_csum = ibmveth_set_rx_csum,
920
877
.get_strings = ibmveth_get_strings,
921
878
.get_sset_count = ibmveth_get_sset_count,
922
879
.get_ethtool_stats = ibmveth_get_ethtool_stats,
923
.set_sg = ethtool_op_set_sg,
926
882
static int ibmveth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1345
1301
.ndo_set_multicast_list = ibmveth_set_multicast_list,
1346
1302
.ndo_do_ioctl = ibmveth_ioctl,
1347
1303
.ndo_change_mtu = ibmveth_change_mtu,
1304
.ndo_fix_features = ibmveth_fix_features,
1305
.ndo_set_features = ibmveth_set_features,
1348
1306
.ndo_validate_addr = eth_validate_addr,
1349
1307
.ndo_set_mac_address = eth_mac_addr,
1350
1308
#ifdef CONFIG_NET_POLL_CONTROLLER
1412
1370
netdev->netdev_ops = &ibmveth_netdev_ops;
1413
1371
netdev->ethtool_ops = &netdev_ethtool_ops;
1414
1372
SET_NETDEV_DEV(netdev, &dev->dev);
1415
netdev->features |= NETIF_F_SG;
1373
netdev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM |
1374
NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
1375
netdev->features |= netdev->hw_features;
1417
1377
memcpy(netdev->dev_addr, &adapter->mac_addr, netdev->addr_len);
1438
1398
netdev_dbg(netdev, "registering netdev...\n");
1440
ibmveth_set_csum_offload(netdev, 1, ibmveth_set_tx_csum_flags);
1400
ibmveth_set_features(netdev, netdev->features);
1442
1402
rc = register_netdev(netdev);