diff options
Diffstat (limited to 'drivers/net/usb/smsc75xx.c')
-rw-r--r-- | drivers/net/usb/smsc75xx.c | 124 |
1 files changed, 44 insertions, 80 deletions
diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c index 753ee6eb7edd..860a20c938b4 100644 --- a/drivers/net/usb/smsc75xx.c +++ b/drivers/net/usb/smsc75xx.c | |||
@@ -65,7 +65,6 @@ struct smsc75xx_priv { | |||
65 | struct usbnet *dev; | 65 | struct usbnet *dev; |
66 | u32 rfe_ctl; | 66 | u32 rfe_ctl; |
67 | u32 multicast_hash_table[DP_SEL_VHF_HASH_LEN]; | 67 | u32 multicast_hash_table[DP_SEL_VHF_HASH_LEN]; |
68 | bool use_rx_csum; | ||
69 | struct mutex dataport_mutex; | 68 | struct mutex dataport_mutex; |
70 | spinlock_t rfe_ctl_lock; | 69 | spinlock_t rfe_ctl_lock; |
71 | struct work_struct set_multicast; | 70 | struct work_struct set_multicast; |
@@ -548,28 +547,6 @@ static void smsc75xx_status(struct usbnet *dev, struct urb *urb) | |||
548 | "unexpected interrupt, intdata=0x%08X", intdata); | 547 | "unexpected interrupt, intdata=0x%08X", intdata); |
549 | } | 548 | } |
550 | 549 | ||
551 | /* Enable or disable Rx checksum offload engine */ | ||
552 | static int smsc75xx_set_rx_csum_offload(struct usbnet *dev) | ||
553 | { | ||
554 | struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); | ||
555 | unsigned long flags; | ||
556 | int ret; | ||
557 | |||
558 | spin_lock_irqsave(&pdata->rfe_ctl_lock, flags); | ||
559 | |||
560 | if (pdata->use_rx_csum) | ||
561 | pdata->rfe_ctl |= RFE_CTL_TCPUDP_CKM | RFE_CTL_IP_CKM; | ||
562 | else | ||
563 | pdata->rfe_ctl &= ~(RFE_CTL_TCPUDP_CKM | RFE_CTL_IP_CKM); | ||
564 | |||
565 | spin_unlock_irqrestore(&pdata->rfe_ctl_lock, flags); | ||
566 | |||
567 | ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl); | ||
568 | check_warn_return(ret, "Error writing RFE_CTL"); | ||
569 | |||
570 | return 0; | ||
571 | } | ||
572 | |||
573 | static int smsc75xx_ethtool_get_eeprom_len(struct net_device *net) | 550 | static int smsc75xx_ethtool_get_eeprom_len(struct net_device *net) |
574 | { | 551 | { |
575 | return MAX_EEPROM_SIZE; | 552 | return MAX_EEPROM_SIZE; |
@@ -599,34 +576,6 @@ static int smsc75xx_ethtool_set_eeprom(struct net_device *netdev, | |||
599 | return smsc75xx_write_eeprom(dev, ee->offset, ee->len, data); | 576 | return smsc75xx_write_eeprom(dev, ee->offset, ee->len, data); |
600 | } | 577 | } |
601 | 578 | ||
602 | static u32 smsc75xx_ethtool_get_rx_csum(struct net_device *netdev) | ||
603 | { | ||
604 | struct usbnet *dev = netdev_priv(netdev); | ||
605 | struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); | ||
606 | |||
607 | return pdata->use_rx_csum; | ||
608 | } | ||
609 | |||
610 | static int smsc75xx_ethtool_set_rx_csum(struct net_device *netdev, u32 val) | ||
611 | { | ||
612 | struct usbnet *dev = netdev_priv(netdev); | ||
613 | struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); | ||
614 | |||
615 | pdata->use_rx_csum = !!val; | ||
616 | |||
617 | return smsc75xx_set_rx_csum_offload(dev); | ||
618 | } | ||
619 | |||
620 | static int smsc75xx_ethtool_set_tso(struct net_device *netdev, u32 data) | ||
621 | { | ||
622 | if (data) | ||
623 | netdev->features |= NETIF_F_TSO | NETIF_F_TSO6; | ||
624 | else | ||
625 | netdev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6); | ||
626 | |||
627 | return 0; | ||
628 | } | ||
629 | |||
630 | static const struct ethtool_ops smsc75xx_ethtool_ops = { | 579 | static const struct ethtool_ops smsc75xx_ethtool_ops = { |
631 | .get_link = usbnet_get_link, | 580 | .get_link = usbnet_get_link, |
632 | .nway_reset = usbnet_nway_reset, | 581 | .nway_reset = usbnet_nway_reset, |
@@ -638,12 +587,6 @@ static const struct ethtool_ops smsc75xx_ethtool_ops = { | |||
638 | .get_eeprom_len = smsc75xx_ethtool_get_eeprom_len, | 587 | .get_eeprom_len = smsc75xx_ethtool_get_eeprom_len, |
639 | .get_eeprom = smsc75xx_ethtool_get_eeprom, | 588 | .get_eeprom = smsc75xx_ethtool_get_eeprom, |
640 | .set_eeprom = smsc75xx_ethtool_set_eeprom, | 589 | .set_eeprom = smsc75xx_ethtool_set_eeprom, |
641 | .get_tx_csum = ethtool_op_get_tx_csum, | ||
642 | .set_tx_csum = ethtool_op_set_tx_hw_csum, | ||
643 | .get_rx_csum = smsc75xx_ethtool_get_rx_csum, | ||
644 | .set_rx_csum = smsc75xx_ethtool_set_rx_csum, | ||
645 | .get_tso = ethtool_op_get_tso, | ||
646 | .set_tso = smsc75xx_ethtool_set_tso, | ||
647 | }; | 590 | }; |
648 | 591 | ||
649 | static int smsc75xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) | 592 | static int smsc75xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) |
@@ -782,6 +725,30 @@ static int smsc75xx_change_mtu(struct net_device *netdev, int new_mtu) | |||
782 | return usbnet_change_mtu(netdev, new_mtu); | 725 | return usbnet_change_mtu(netdev, new_mtu); |
783 | } | 726 | } |
784 | 727 | ||
728 | /* Enable or disable Rx checksum offload engine */ | ||
729 | static int smsc75xx_set_features(struct net_device *netdev, u32 features) | ||
730 | { | ||
731 | struct usbnet *dev = netdev_priv(netdev); | ||
732 | struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); | ||
733 | unsigned long flags; | ||
734 | int ret; | ||
735 | |||
736 | spin_lock_irqsave(&pdata->rfe_ctl_lock, flags); | ||
737 | |||
738 | if (features & NETIF_F_RXCSUM) | ||
739 | pdata->rfe_ctl |= RFE_CTL_TCPUDP_CKM | RFE_CTL_IP_CKM; | ||
740 | else | ||
741 | pdata->rfe_ctl &= ~(RFE_CTL_TCPUDP_CKM | RFE_CTL_IP_CKM); | ||
742 | |||
743 | spin_unlock_irqrestore(&pdata->rfe_ctl_lock, flags); | ||
744 | /* it's racing here! */ | ||
745 | |||
746 | ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl); | ||
747 | check_warn_return(ret, "Error writing RFE_CTL"); | ||
748 | |||
749 | return 0; | ||
750 | } | ||
751 | |||
785 | static int smsc75xx_reset(struct usbnet *dev) | 752 | static int smsc75xx_reset(struct usbnet *dev) |
786 | { | 753 | { |
787 | struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); | 754 | struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); |
@@ -960,11 +927,7 @@ static int smsc75xx_reset(struct usbnet *dev) | |||
960 | netif_dbg(dev, ifup, dev->net, "RFE_CTL set to 0x%08x", pdata->rfe_ctl); | 927 | netif_dbg(dev, ifup, dev->net, "RFE_CTL set to 0x%08x", pdata->rfe_ctl); |
961 | 928 | ||
962 | /* Enable or disable checksum offload engines */ | 929 | /* Enable or disable checksum offload engines */ |
963 | ethtool_op_set_tx_hw_csum(dev->net, DEFAULT_TX_CSUM_ENABLE); | 930 | smsc75xx_set_features(dev->net, dev->net->features); |
964 | ret = smsc75xx_set_rx_csum_offload(dev); | ||
965 | check_warn_return(ret, "Failed to set rx csum offload: %d", ret); | ||
966 | |||
967 | smsc75xx_ethtool_set_tso(dev->net, DEFAULT_TSO_ENABLE); | ||
968 | 931 | ||
969 | smsc75xx_set_multicast(dev->net); | 932 | smsc75xx_set_multicast(dev->net); |
970 | 933 | ||
@@ -1037,6 +1000,7 @@ static const struct net_device_ops smsc75xx_netdev_ops = { | |||
1037 | .ndo_validate_addr = eth_validate_addr, | 1000 | .ndo_validate_addr = eth_validate_addr, |
1038 | .ndo_do_ioctl = smsc75xx_ioctl, | 1001 | .ndo_do_ioctl = smsc75xx_ioctl, |
1039 | .ndo_set_multicast_list = smsc75xx_set_multicast, | 1002 | .ndo_set_multicast_list = smsc75xx_set_multicast, |
1003 | .ndo_set_features = smsc75xx_set_features, | ||
1040 | }; | 1004 | }; |
1041 | 1005 | ||
1042 | static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf) | 1006 | static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf) |
@@ -1065,10 +1029,17 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf) | |||
1065 | 1029 | ||
1066 | INIT_WORK(&pdata->set_multicast, smsc75xx_deferred_multicast_write); | 1030 | INIT_WORK(&pdata->set_multicast, smsc75xx_deferred_multicast_write); |
1067 | 1031 | ||
1068 | pdata->use_rx_csum = DEFAULT_RX_CSUM_ENABLE; | 1032 | if (DEFAULT_TX_CSUM_ENABLE) { |
1033 | dev->net->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; | ||
1034 | if (DEFAULT_TSO_ENABLE) | ||
1035 | dev->net->features |= NETIF_F_SG | | ||
1036 | NETIF_F_TSO | NETIF_F_TSO6; | ||
1037 | } | ||
1038 | if (DEFAULT_RX_CSUM_ENABLE) | ||
1039 | dev->net->features |= NETIF_F_RXCSUM; | ||
1069 | 1040 | ||
1070 | /* We have to advertise SG otherwise TSO cannot be enabled */ | 1041 | dev->net->hw_features = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | |
1071 | dev->net->features |= NETIF_F_SG; | 1042 | NETIF_F_SG | NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_RXCSUM; |
1072 | 1043 | ||
1073 | /* Init all registers */ | 1044 | /* Init all registers */ |
1074 | ret = smsc75xx_reset(dev); | 1045 | ret = smsc75xx_reset(dev); |
@@ -1091,10 +1062,11 @@ static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf) | |||
1091 | } | 1062 | } |
1092 | } | 1063 | } |
1093 | 1064 | ||
1094 | static void smsc75xx_rx_csum_offload(struct sk_buff *skb, u32 rx_cmd_a, | 1065 | static void smsc75xx_rx_csum_offload(struct usbnet *dev, struct sk_buff *skb, |
1095 | u32 rx_cmd_b) | 1066 | u32 rx_cmd_a, u32 rx_cmd_b) |
1096 | { | 1067 | { |
1097 | if (unlikely(rx_cmd_a & RX_CMD_A_LCSM)) { | 1068 | if (!(dev->net->features & NETIF_F_RXCSUM) || |
1069 | unlikely(rx_cmd_a & RX_CMD_A_LCSM)) { | ||
1098 | skb->ip_summed = CHECKSUM_NONE; | 1070 | skb->ip_summed = CHECKSUM_NONE; |
1099 | } else { | 1071 | } else { |
1100 | skb->csum = ntohs((u16)(rx_cmd_b >> RX_CMD_B_CSUM_SHIFT)); | 1072 | skb->csum = ntohs((u16)(rx_cmd_b >> RX_CMD_B_CSUM_SHIFT)); |
@@ -1104,8 +1076,6 @@ static void smsc75xx_rx_csum_offload(struct sk_buff *skb, u32 rx_cmd_a, | |||
1104 | 1076 | ||
1105 | static int smsc75xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | 1077 | static int smsc75xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb) |
1106 | { | 1078 | { |
1107 | struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); | ||
1108 | |||
1109 | while (skb->len > 0) { | 1079 | while (skb->len > 0) { |
1110 | u32 rx_cmd_a, rx_cmd_b, align_count, size; | 1080 | u32 rx_cmd_a, rx_cmd_b, align_count, size; |
1111 | struct sk_buff *ax_skb; | 1081 | struct sk_buff *ax_skb; |
@@ -1145,11 +1115,8 @@ static int smsc75xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |||
1145 | 1115 | ||
1146 | /* last frame in this batch */ | 1116 | /* last frame in this batch */ |
1147 | if (skb->len == size) { | 1117 | if (skb->len == size) { |
1148 | if (pdata->use_rx_csum) | 1118 | smsc75xx_rx_csum_offload(dev, skb, rx_cmd_a, |
1149 | smsc75xx_rx_csum_offload(skb, rx_cmd_a, | 1119 | rx_cmd_b); |
1150 | rx_cmd_b); | ||
1151 | else | ||
1152 | skb->ip_summed = CHECKSUM_NONE; | ||
1153 | 1120 | ||
1154 | skb_trim(skb, skb->len - 4); /* remove fcs */ | 1121 | skb_trim(skb, skb->len - 4); /* remove fcs */ |
1155 | skb->truesize = size + sizeof(struct sk_buff); | 1122 | skb->truesize = size + sizeof(struct sk_buff); |
@@ -1167,11 +1134,8 @@ static int smsc75xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |||
1167 | ax_skb->data = packet; | 1134 | ax_skb->data = packet; |
1168 | skb_set_tail_pointer(ax_skb, size); | 1135 | skb_set_tail_pointer(ax_skb, size); |
1169 | 1136 | ||
1170 | if (pdata->use_rx_csum) | 1137 | smsc75xx_rx_csum_offload(dev, ax_skb, rx_cmd_a, |
1171 | smsc75xx_rx_csum_offload(ax_skb, rx_cmd_a, | 1138 | rx_cmd_b); |
1172 | rx_cmd_b); | ||
1173 | else | ||
1174 | ax_skb->ip_summed = CHECKSUM_NONE; | ||
1175 | 1139 | ||
1176 | skb_trim(ax_skb, ax_skb->len - 4); /* remove fcs */ | 1140 | skb_trim(ax_skb, ax_skb->len - 4); /* remove fcs */ |
1177 | ax_skb->truesize = size + sizeof(struct sk_buff); | 1141 | ax_skb->truesize = size + sizeof(struct sk_buff); |