~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/net/ibmveth.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
710
710
                                SUPPORTED_FIBRE);
711
711
        cmd->advertising = (ADVERTISED_1000baseT_Full | ADVERTISED_Autoneg |
712
712
                                ADVERTISED_FIBRE);
713
 
        cmd->speed = SPEED_1000;
 
713
        ethtool_cmd_speed_set(cmd, SPEED_1000);
714
714
        cmd->duplex = DUPLEX_FULL;
715
715
        cmd->port = PORT_FIBRE;
716
716
        cmd->phy_address = 0;
729
729
                sizeof(info->version) - 1);
730
730
}
731
731
 
732
 
static void ibmveth_set_rx_csum_flags(struct net_device *dev, u32 data)
733
 
{
734
 
        struct ibmveth_adapter *adapter = netdev_priv(dev);
735
 
 
736
 
        if (data) {
737
 
                adapter->rx_csum = 1;
738
 
        } else {
739
 
                /*
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
745
 
                 * checksummed.
746
 
                 */
747
 
                adapter->rx_csum = 0;
748
 
                dev->features &= ~NETIF_F_IP_CSUM;
749
 
                dev->features &= ~NETIF_F_IPV6_CSUM;
750
 
        }
751
 
}
752
 
 
753
 
static void ibmveth_set_tx_csum_flags(struct net_device *dev, u32 data)
754
 
{
755
 
        struct ibmveth_adapter *adapter = netdev_priv(dev);
756
 
 
757
 
        if (data) {
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;
763
 
        } else {
764
 
                dev->features &= ~NETIF_F_IP_CSUM;
765
 
                dev->features &= ~NETIF_F_IPV6_CSUM;
766
 
        }
767
 
}
768
 
 
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)
 
733
{
 
734
        /*
 
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
 
740
         * checksummed.
 
741
         */
 
742
 
 
743
        if (!(features & NETIF_F_RXCSUM))
 
744
                features &= ~NETIF_F_ALL_CSUM;
 
745
 
 
746
        return features;
 
747
}
 
748
 
 
749
static int ibmveth_set_csum_offload(struct net_device *dev, u32 data)
771
750
{
772
751
        struct ibmveth_adapter *adapter = netdev_priv(dev);
773
752
        unsigned long set_attr, clr_attr, ret_attr;
827
806
                } else
828
807
                        adapter->fw_ipv6_csum_support = data;
829
808
 
830
 
                if (ret == H_SUCCESS || ret6 == H_SUCCESS)
831
 
                        done(dev, data);
 
809
                if (ret != H_SUCCESS || ret6 != H_SUCCESS)
 
810
                        adapter->rx_csum = data;
832
811
                else
833
812
                        rc1 = -EIO;
834
813
        } else {
844
823
        return rc1 ? rc1 : rc2;
845
824
}
846
825
 
847
 
static int ibmveth_set_rx_csum(struct net_device *dev, u32 data)
848
 
{
849
 
        struct ibmveth_adapter *adapter = netdev_priv(dev);
850
 
 
851
 
        if ((data && adapter->rx_csum) || (!data && !adapter->rx_csum))
852
 
                return 0;
853
 
 
854
 
        return ibmveth_set_csum_offload(dev, data, ibmveth_set_rx_csum_flags);
855
 
}
856
 
 
857
 
static int ibmveth_set_tx_csum(struct net_device *dev, u32 data)
858
 
{
859
 
        struct ibmveth_adapter *adapter = netdev_priv(dev);
860
 
        int rc = 0;
861
 
 
862
 
        if (data && (dev->features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)))
863
 
                return 0;
864
 
        if (!data && !(dev->features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)))
865
 
                return 0;
866
 
 
867
 
        if (data && !adapter->rx_csum)
868
 
                rc = ibmveth_set_csum_offload(dev, data,
869
 
                                              ibmveth_set_tx_csum_flags);
870
 
        else
871
 
                ibmveth_set_tx_csum_flags(dev, data);
 
826
static int ibmveth_set_features(struct net_device *dev, u32 features)
 
827
{
 
828
        struct ibmveth_adapter *adapter = netdev_priv(dev);
 
829
        int rx_csum = !!(features & NETIF_F_RXCSUM);
 
830
        int rc;
 
831
 
 
832
        if (rx_csum == adapter->rx_csum)
 
833
                return 0;
 
834
 
 
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);
872
838
 
873
839
        return rc;
874
840
}
875
841
 
876
 
static u32 ibmveth_get_rx_csum(struct net_device *dev)
877
 
{
878
 
        struct ibmveth_adapter *adapter = netdev_priv(dev);
879
 
        return adapter->rx_csum;
880
 
}
881
 
 
882
842
static void ibmveth_get_strings(struct net_device *dev, u32 stringset, u8 *data)
883
843
{
884
844
        int i;
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,
924
880
};
925
881
 
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;
1416
1376
 
1417
1377
        memcpy(netdev->dev_addr, &adapter->mac_addr, netdev->addr_len);
1418
1378
 
1437
1397
 
1438
1398
        netdev_dbg(netdev, "registering netdev...\n");
1439
1399
 
1440
 
        ibmveth_set_csum_offload(netdev, 1, ibmveth_set_tx_csum_flags);
 
1400
        ibmveth_set_features(netdev, netdev->features);
1441
1401
 
1442
1402
        rc = register_netdev(netdev);
1443
1403