diff options
| author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-06-20 19:24:02 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-06-20 19:24:02 -0400 |
| commit | ff446f2001cf9b5ed97c6256c4ee3549d3b7abed (patch) | |
| tree | ec5fd60a8b9c21ae85eaa99003f26e6c342e2234 /drivers/net | |
| parent | 78091dc2f6f04b03131218df590c877cadcd9379 (diff) | |
| parent | 485802a6c524e62b5924849dd727ddbb1497cc71 (diff) | |
Merge 3.5-rc3 into usb-next
This lets us catch the USB fixes that went into 3.5-rc3 into this branch,
as we want them here as well.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/net')
53 files changed, 2262 insertions, 196 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 2ee8cf9e8a3b..b9c2ae62166d 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
| @@ -76,6 +76,7 @@ | |||
| 76 | #include <net/route.h> | 76 | #include <net/route.h> |
| 77 | #include <net/net_namespace.h> | 77 | #include <net/net_namespace.h> |
| 78 | #include <net/netns/generic.h> | 78 | #include <net/netns/generic.h> |
| 79 | #include <net/pkt_sched.h> | ||
| 79 | #include "bonding.h" | 80 | #include "bonding.h" |
| 80 | #include "bond_3ad.h" | 81 | #include "bond_3ad.h" |
| 81 | #include "bond_alb.h" | 82 | #include "bond_alb.h" |
| @@ -381,8 +382,6 @@ struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr) | |||
| 381 | return next; | 382 | return next; |
| 382 | } | 383 | } |
| 383 | 384 | ||
| 384 | #define bond_queue_mapping(skb) (*(u16 *)((skb)->cb)) | ||
| 385 | |||
| 386 | /** | 385 | /** |
| 387 | * bond_dev_queue_xmit - Prepare skb for xmit. | 386 | * bond_dev_queue_xmit - Prepare skb for xmit. |
| 388 | * | 387 | * |
| @@ -395,7 +394,9 @@ int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, | |||
| 395 | { | 394 | { |
| 396 | skb->dev = slave_dev; | 395 | skb->dev = slave_dev; |
| 397 | 396 | ||
| 398 | skb->queue_mapping = bond_queue_mapping(skb); | 397 | BUILD_BUG_ON(sizeof(skb->queue_mapping) != |
| 398 | sizeof(qdisc_skb_cb(skb)->bond_queue_mapping)); | ||
| 399 | skb->queue_mapping = qdisc_skb_cb(skb)->bond_queue_mapping; | ||
| 399 | 400 | ||
| 400 | if (unlikely(netpoll_tx_running(slave_dev))) | 401 | if (unlikely(netpoll_tx_running(slave_dev))) |
| 401 | bond_netpoll_send_skb(bond_get_slave_by_dev(bond, slave_dev), skb); | 402 | bond_netpoll_send_skb(bond_get_slave_by_dev(bond, slave_dev), skb); |
| @@ -4171,7 +4172,7 @@ static u16 bond_select_queue(struct net_device *dev, struct sk_buff *skb) | |||
| 4171 | /* | 4172 | /* |
| 4172 | * Save the original txq to restore before passing to the driver | 4173 | * Save the original txq to restore before passing to the driver |
| 4173 | */ | 4174 | */ |
| 4174 | bond_queue_mapping(skb) = skb->queue_mapping; | 4175 | qdisc_skb_cb(skb)->bond_queue_mapping = skb->queue_mapping; |
| 4175 | 4176 | ||
| 4176 | if (unlikely(txq >= dev->real_num_tx_queues)) { | 4177 | if (unlikely(txq >= dev->real_num_tx_queues)) { |
| 4177 | do { | 4178 | do { |
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index aef42f045320..485bedb8278c 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
| @@ -1082,8 +1082,12 @@ static ssize_t bonding_store_primary(struct device *d, | |||
| 1082 | } | 1082 | } |
| 1083 | } | 1083 | } |
| 1084 | 1084 | ||
| 1085 | pr_info("%s: Unable to set %.*s as primary slave.\n", | 1085 | strncpy(bond->params.primary, ifname, IFNAMSIZ); |
| 1086 | bond->dev->name, (int)strlen(buf) - 1, buf); | 1086 | bond->params.primary[IFNAMSIZ - 1] = 0; |
| 1087 | |||
| 1088 | pr_info("%s: Recording %s as primary, " | ||
| 1089 | "but it has not been enslaved to %s yet.\n", | ||
| 1090 | bond->dev->name, ifname, bond->dev->name); | ||
| 1087 | out: | 1091 | out: |
| 1088 | write_unlock_bh(&bond->curr_slave_lock); | 1092 | write_unlock_bh(&bond->curr_slave_lock); |
| 1089 | read_unlock(&bond->lock); | 1093 | read_unlock(&bond->lock); |
diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c index 536bda072a16..8dc84d66eea1 100644 --- a/drivers/net/can/c_can/c_can.c +++ b/drivers/net/can/c_can/c_can.c | |||
| @@ -686,7 +686,7 @@ static int c_can_get_berr_counter(const struct net_device *dev, | |||
| 686 | * | 686 | * |
| 687 | * We iterate from priv->tx_echo to priv->tx_next and check if the | 687 | * We iterate from priv->tx_echo to priv->tx_next and check if the |
| 688 | * packet has been transmitted, echo it back to the CAN framework. | 688 | * packet has been transmitted, echo it back to the CAN framework. |
| 689 | * If we discover a not yet transmitted package, stop looking for more. | 689 | * If we discover a not yet transmitted packet, stop looking for more. |
| 690 | */ | 690 | */ |
| 691 | static void c_can_do_tx(struct net_device *dev) | 691 | static void c_can_do_tx(struct net_device *dev) |
| 692 | { | 692 | { |
| @@ -698,7 +698,7 @@ static void c_can_do_tx(struct net_device *dev) | |||
| 698 | for (/* nix */; (priv->tx_next - priv->tx_echo) > 0; priv->tx_echo++) { | 698 | for (/* nix */; (priv->tx_next - priv->tx_echo) > 0; priv->tx_echo++) { |
| 699 | msg_obj_no = get_tx_echo_msg_obj(priv); | 699 | msg_obj_no = get_tx_echo_msg_obj(priv); |
| 700 | val = c_can_read_reg32(priv, &priv->regs->txrqst1); | 700 | val = c_can_read_reg32(priv, &priv->regs->txrqst1); |
| 701 | if (!(val & (1 << msg_obj_no))) { | 701 | if (!(val & (1 << (msg_obj_no - 1)))) { |
| 702 | can_get_echo_skb(dev, | 702 | can_get_echo_skb(dev, |
| 703 | msg_obj_no - C_CAN_MSG_OBJ_TX_FIRST); | 703 | msg_obj_no - C_CAN_MSG_OBJ_TX_FIRST); |
| 704 | stats->tx_bytes += priv->read_reg(priv, | 704 | stats->tx_bytes += priv->read_reg(priv, |
| @@ -706,6 +706,8 @@ static void c_can_do_tx(struct net_device *dev) | |||
| 706 | & IF_MCONT_DLC_MASK; | 706 | & IF_MCONT_DLC_MASK; |
| 707 | stats->tx_packets++; | 707 | stats->tx_packets++; |
| 708 | c_can_inval_msg_object(dev, 0, msg_obj_no); | 708 | c_can_inval_msg_object(dev, 0, msg_obj_no); |
| 709 | } else { | ||
| 710 | break; | ||
| 709 | } | 711 | } |
| 710 | } | 712 | } |
| 711 | 713 | ||
| @@ -950,7 +952,7 @@ static int c_can_poll(struct napi_struct *napi, int quota) | |||
| 950 | struct net_device *dev = napi->dev; | 952 | struct net_device *dev = napi->dev; |
| 951 | struct c_can_priv *priv = netdev_priv(dev); | 953 | struct c_can_priv *priv = netdev_priv(dev); |
| 952 | 954 | ||
| 953 | irqstatus = priv->read_reg(priv, &priv->regs->interrupt); | 955 | irqstatus = priv->irqstatus; |
| 954 | if (!irqstatus) | 956 | if (!irqstatus) |
| 955 | goto end; | 957 | goto end; |
| 956 | 958 | ||
| @@ -1028,12 +1030,11 @@ end: | |||
| 1028 | 1030 | ||
| 1029 | static irqreturn_t c_can_isr(int irq, void *dev_id) | 1031 | static irqreturn_t c_can_isr(int irq, void *dev_id) |
| 1030 | { | 1032 | { |
| 1031 | u16 irqstatus; | ||
| 1032 | struct net_device *dev = (struct net_device *)dev_id; | 1033 | struct net_device *dev = (struct net_device *)dev_id; |
| 1033 | struct c_can_priv *priv = netdev_priv(dev); | 1034 | struct c_can_priv *priv = netdev_priv(dev); |
| 1034 | 1035 | ||
| 1035 | irqstatus = priv->read_reg(priv, &priv->regs->interrupt); | 1036 | priv->irqstatus = priv->read_reg(priv, &priv->regs->interrupt); |
| 1036 | if (!irqstatus) | 1037 | if (!priv->irqstatus) |
| 1037 | return IRQ_NONE; | 1038 | return IRQ_NONE; |
| 1038 | 1039 | ||
| 1039 | /* disable all interrupts and schedule the NAPI */ | 1040 | /* disable all interrupts and schedule the NAPI */ |
| @@ -1063,10 +1064,11 @@ static int c_can_open(struct net_device *dev) | |||
| 1063 | goto exit_irq_fail; | 1064 | goto exit_irq_fail; |
| 1064 | } | 1065 | } |
| 1065 | 1066 | ||
| 1067 | napi_enable(&priv->napi); | ||
| 1068 | |||
| 1066 | /* start the c_can controller */ | 1069 | /* start the c_can controller */ |
| 1067 | c_can_start(dev); | 1070 | c_can_start(dev); |
| 1068 | 1071 | ||
| 1069 | napi_enable(&priv->napi); | ||
| 1070 | netif_start_queue(dev); | 1072 | netif_start_queue(dev); |
| 1071 | 1073 | ||
| 1072 | return 0; | 1074 | return 0; |
diff --git a/drivers/net/can/c_can/c_can.h b/drivers/net/can/c_can/c_can.h index 9b7fbef3d09a..5f32d34af507 100644 --- a/drivers/net/can/c_can/c_can.h +++ b/drivers/net/can/c_can/c_can.h | |||
| @@ -76,6 +76,7 @@ struct c_can_priv { | |||
| 76 | unsigned int tx_next; | 76 | unsigned int tx_next; |
| 77 | unsigned int tx_echo; | 77 | unsigned int tx_echo; |
| 78 | void *priv; /* for board-specific data */ | 78 | void *priv; /* for board-specific data */ |
| 79 | u16 irqstatus; | ||
| 79 | }; | 80 | }; |
| 80 | 81 | ||
| 81 | struct net_device *alloc_c_can_dev(void); | 82 | struct net_device *alloc_c_can_dev(void); |
diff --git a/drivers/net/can/cc770/cc770_platform.c b/drivers/net/can/cc770/cc770_platform.c index 53115eee8075..688371cda37a 100644 --- a/drivers/net/can/cc770/cc770_platform.c +++ b/drivers/net/can/cc770/cc770_platform.c | |||
| @@ -154,7 +154,7 @@ static int __devinit cc770_get_platform_data(struct platform_device *pdev, | |||
| 154 | struct cc770_platform_data *pdata = pdev->dev.platform_data; | 154 | struct cc770_platform_data *pdata = pdev->dev.platform_data; |
| 155 | 155 | ||
| 156 | priv->can.clock.freq = pdata->osc_freq; | 156 | priv->can.clock.freq = pdata->osc_freq; |
| 157 | if (priv->cpu_interface | CPUIF_DSC) | 157 | if (priv->cpu_interface & CPUIF_DSC) |
| 158 | priv->can.clock.freq /= 2; | 158 | priv->can.clock.freq /= 2; |
| 159 | priv->clkout = pdata->cor; | 159 | priv->clkout = pdata->cor; |
| 160 | priv->bus_config = pdata->bcr; | 160 | priv->bus_config = pdata->bcr; |
diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c index 442d91a2747b..bab0158f1cc3 100644 --- a/drivers/net/dummy.c +++ b/drivers/net/dummy.c | |||
| @@ -187,8 +187,10 @@ static int __init dummy_init_module(void) | |||
| 187 | rtnl_lock(); | 187 | rtnl_lock(); |
| 188 | err = __rtnl_link_register(&dummy_link_ops); | 188 | err = __rtnl_link_register(&dummy_link_ops); |
| 189 | 189 | ||
| 190 | for (i = 0; i < numdummies && !err; i++) | 190 | for (i = 0; i < numdummies && !err; i++) { |
| 191 | err = dummy_init_one(); | 191 | err = dummy_init_one(); |
| 192 | cond_resched(); | ||
| 193 | } | ||
| 192 | if (err < 0) | 194 | if (err < 0) |
| 193 | __rtnl_link_unregister(&dummy_link_ops); | 195 | __rtnl_link_unregister(&dummy_link_ops); |
| 194 | rtnl_unlock(); | 196 | rtnl_unlock(); |
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index e30e2a2f354c..7de824184979 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | |||
| @@ -747,21 +747,6 @@ struct bnx2x_fastpath { | |||
| 747 | 747 | ||
| 748 | #define ETH_RX_ERROR_FALGS ETH_FAST_PATH_RX_CQE_PHY_DECODE_ERR_FLG | 748 | #define ETH_RX_ERROR_FALGS ETH_FAST_PATH_RX_CQE_PHY_DECODE_ERR_FLG |
| 749 | 749 | ||
| 750 | #define BNX2X_IP_CSUM_ERR(cqe) \ | ||
| 751 | (!((cqe)->fast_path_cqe.status_flags & \ | ||
| 752 | ETH_FAST_PATH_RX_CQE_IP_XSUM_NO_VALIDATION_FLG) && \ | ||
| 753 | ((cqe)->fast_path_cqe.type_error_flags & \ | ||
| 754 | ETH_FAST_PATH_RX_CQE_IP_BAD_XSUM_FLG)) | ||
| 755 | |||
| 756 | #define BNX2X_L4_CSUM_ERR(cqe) \ | ||
| 757 | (!((cqe)->fast_path_cqe.status_flags & \ | ||
| 758 | ETH_FAST_PATH_RX_CQE_L4_XSUM_NO_VALIDATION_FLG) && \ | ||
| 759 | ((cqe)->fast_path_cqe.type_error_flags & \ | ||
| 760 | ETH_FAST_PATH_RX_CQE_L4_BAD_XSUM_FLG)) | ||
| 761 | |||
| 762 | #define BNX2X_RX_CSUM_OK(cqe) \ | ||
| 763 | (!(BNX2X_L4_CSUM_ERR(cqe) || BNX2X_IP_CSUM_ERR(cqe))) | ||
| 764 | |||
| 765 | #define BNX2X_PRS_FLAG_OVERETH_IPV4(flags) \ | 750 | #define BNX2X_PRS_FLAG_OVERETH_IPV4(flags) \ |
| 766 | (((le16_to_cpu(flags) & \ | 751 | (((le16_to_cpu(flags) & \ |
| 767 | PARSING_FLAGS_OVER_ETHERNET_PROTOCOL) >> \ | 752 | PARSING_FLAGS_OVER_ETHERNET_PROTOCOL) >> \ |
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index ad0743bf4bde..cbc56f274e0c 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | |||
| @@ -617,6 +617,25 @@ static int bnx2x_alloc_rx_data(struct bnx2x *bp, | |||
| 617 | return 0; | 617 | return 0; |
| 618 | } | 618 | } |
| 619 | 619 | ||
| 620 | static void bnx2x_csum_validate(struct sk_buff *skb, union eth_rx_cqe *cqe, | ||
| 621 | struct bnx2x_fastpath *fp) | ||
| 622 | { | ||
| 623 | /* Do nothing if no IP/L4 csum validation was done */ | ||
| 624 | |||
| 625 | if (cqe->fast_path_cqe.status_flags & | ||
| 626 | (ETH_FAST_PATH_RX_CQE_IP_XSUM_NO_VALIDATION_FLG | | ||
| 627 | ETH_FAST_PATH_RX_CQE_L4_XSUM_NO_VALIDATION_FLG)) | ||
| 628 | return; | ||
| 629 | |||
| 630 | /* If both IP/L4 validation were done, check if an error was found. */ | ||
| 631 | |||
| 632 | if (cqe->fast_path_cqe.type_error_flags & | ||
| 633 | (ETH_FAST_PATH_RX_CQE_IP_BAD_XSUM_FLG | | ||
| 634 | ETH_FAST_PATH_RX_CQE_L4_BAD_XSUM_FLG)) | ||
| 635 | fp->eth_q_stats.hw_csum_err++; | ||
| 636 | else | ||
| 637 | skb->ip_summed = CHECKSUM_UNNECESSARY; | ||
| 638 | } | ||
| 620 | 639 | ||
| 621 | int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) | 640 | int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) |
| 622 | { | 641 | { |
| @@ -806,13 +825,9 @@ reuse_rx: | |||
| 806 | 825 | ||
| 807 | skb_checksum_none_assert(skb); | 826 | skb_checksum_none_assert(skb); |
| 808 | 827 | ||
| 809 | if (bp->dev->features & NETIF_F_RXCSUM) { | 828 | if (bp->dev->features & NETIF_F_RXCSUM) |
| 829 | bnx2x_csum_validate(skb, cqe, fp); | ||
| 810 | 830 | ||
| 811 | if (likely(BNX2X_RX_CSUM_OK(cqe))) | ||
| 812 | skb->ip_summed = CHECKSUM_UNNECESSARY; | ||
| 813 | else | ||
| 814 | fp->eth_q_stats.hw_csum_err++; | ||
| 815 | } | ||
| 816 | 831 | ||
| 817 | skb_record_rx_queue(skb, fp->rx_queue); | 832 | skb_record_rx_queue(skb, fp->rx_queue); |
| 818 | 833 | ||
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index edeeb516807a..e47ff8be1d7b 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c | |||
| @@ -14275,7 +14275,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
| 14275 | } | 14275 | } |
| 14276 | } | 14276 | } |
| 14277 | 14277 | ||
| 14278 | if (tg3_flag(tp, 5755_PLUS)) | 14278 | if (tg3_flag(tp, 5755_PLUS) || |
| 14279 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) | ||
| 14279 | tg3_flag_set(tp, SHORT_DMA_BUG); | 14280 | tg3_flag_set(tp, SHORT_DMA_BUG); |
| 14280 | 14281 | ||
| 14281 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719) | 14282 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719) |
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 08efd308d78a..fdb50cec6b51 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c | |||
| @@ -736,6 +736,8 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, | |||
| 736 | 736 | ||
| 737 | copied = make_tx_wrbs(adapter, txq, skb, wrb_cnt, dummy_wrb); | 737 | copied = make_tx_wrbs(adapter, txq, skb, wrb_cnt, dummy_wrb); |
| 738 | if (copied) { | 738 | if (copied) { |
| 739 | int gso_segs = skb_shinfo(skb)->gso_segs; | ||
| 740 | |||
| 739 | /* record the sent skb in the sent_skb table */ | 741 | /* record the sent skb in the sent_skb table */ |
| 740 | BUG_ON(txo->sent_skb_list[start]); | 742 | BUG_ON(txo->sent_skb_list[start]); |
| 741 | txo->sent_skb_list[start] = skb; | 743 | txo->sent_skb_list[start] = skb; |
| @@ -753,8 +755,7 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, | |||
| 753 | 755 | ||
| 754 | be_txq_notify(adapter, txq->id, wrb_cnt); | 756 | be_txq_notify(adapter, txq->id, wrb_cnt); |
| 755 | 757 | ||
| 756 | be_tx_stats_update(txo, wrb_cnt, copied, | 758 | be_tx_stats_update(txo, wrb_cnt, copied, gso_segs, stopped); |
| 757 | skb_shinfo(skb)->gso_segs, stopped); | ||
| 758 | } else { | 759 | } else { |
| 759 | txq->head = start; | 760 | txq->head = start; |
| 760 | dev_kfree_skb_any(skb); | 761 | dev_kfree_skb_any(skb); |
diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c index d863075df7a4..905e2147d918 100644 --- a/drivers/net/ethernet/intel/e1000e/ethtool.c +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c | |||
| @@ -258,7 +258,8 @@ static int e1000_set_settings(struct net_device *netdev, | |||
| 258 | * When SoL/IDER sessions are active, autoneg/speed/duplex | 258 | * When SoL/IDER sessions are active, autoneg/speed/duplex |
| 259 | * cannot be changed | 259 | * cannot be changed |
| 260 | */ | 260 | */ |
| 261 | if (hw->phy.ops.check_reset_block(hw)) { | 261 | if (hw->phy.ops.check_reset_block && |
| 262 | hw->phy.ops.check_reset_block(hw)) { | ||
| 262 | e_err("Cannot change link characteristics when SoL/IDER is active.\n"); | 263 | e_err("Cannot change link characteristics when SoL/IDER is active.\n"); |
| 263 | return -EINVAL; | 264 | return -EINVAL; |
| 264 | } | 265 | } |
| @@ -1615,7 +1616,8 @@ static int e1000_loopback_test(struct e1000_adapter *adapter, u64 *data) | |||
| 1615 | * PHY loopback cannot be performed if SoL/IDER | 1616 | * PHY loopback cannot be performed if SoL/IDER |
| 1616 | * sessions are active | 1617 | * sessions are active |
| 1617 | */ | 1618 | */ |
| 1618 | if (hw->phy.ops.check_reset_block(hw)) { | 1619 | if (hw->phy.ops.check_reset_block && |
| 1620 | hw->phy.ops.check_reset_block(hw)) { | ||
| 1619 | e_err("Cannot do PHY loopback test when SoL/IDER is active.\n"); | 1621 | e_err("Cannot do PHY loopback test when SoL/IDER is active.\n"); |
| 1620 | *data = 0; | 1622 | *data = 0; |
| 1621 | goto out; | 1623 | goto out; |
diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index 026e8b3ab52e..a13439928488 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c | |||
| @@ -709,7 +709,7 @@ s32 e1000e_setup_link_generic(struct e1000_hw *hw) | |||
| 709 | * In the case of the phy reset being blocked, we already have a link. | 709 | * In the case of the phy reset being blocked, we already have a link. |
| 710 | * We do not need to set it up again. | 710 | * We do not need to set it up again. |
| 711 | */ | 711 | */ |
| 712 | if (hw->phy.ops.check_reset_block(hw)) | 712 | if (hw->phy.ops.check_reset_block && hw->phy.ops.check_reset_block(hw)) |
| 713 | return 0; | 713 | return 0; |
| 714 | 714 | ||
| 715 | /* | 715 | /* |
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index a4b0435b00dc..31d37a2b5ba8 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c | |||
| @@ -6237,7 +6237,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, | |||
| 6237 | adapter->hw.phy.ms_type = e1000_ms_hw_default; | 6237 | adapter->hw.phy.ms_type = e1000_ms_hw_default; |
| 6238 | } | 6238 | } |
| 6239 | 6239 | ||
| 6240 | if (hw->phy.ops.check_reset_block(hw)) | 6240 | if (hw->phy.ops.check_reset_block && hw->phy.ops.check_reset_block(hw)) |
| 6241 | e_info("PHY reset is blocked due to SOL/IDER session.\n"); | 6241 | e_info("PHY reset is blocked due to SOL/IDER session.\n"); |
| 6242 | 6242 | ||
| 6243 | /* Set initial default active device features */ | 6243 | /* Set initial default active device features */ |
| @@ -6404,7 +6404,7 @@ err_register: | |||
| 6404 | if (!(adapter->flags & FLAG_HAS_AMT)) | 6404 | if (!(adapter->flags & FLAG_HAS_AMT)) |
| 6405 | e1000e_release_hw_control(adapter); | 6405 | e1000e_release_hw_control(adapter); |
| 6406 | err_eeprom: | 6406 | err_eeprom: |
| 6407 | if (!hw->phy.ops.check_reset_block(hw)) | 6407 | if (hw->phy.ops.check_reset_block && !hw->phy.ops.check_reset_block(hw)) |
| 6408 | e1000_phy_hw_reset(&adapter->hw); | 6408 | e1000_phy_hw_reset(&adapter->hw); |
| 6409 | err_hw_init: | 6409 | err_hw_init: |
| 6410 | kfree(adapter->tx_ring); | 6410 | kfree(adapter->tx_ring); |
diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c index 0334d013bc3c..b860d4f7ea2a 100644 --- a/drivers/net/ethernet/intel/e1000e/phy.c +++ b/drivers/net/ethernet/intel/e1000e/phy.c | |||
| @@ -2155,9 +2155,11 @@ s32 e1000e_phy_hw_reset_generic(struct e1000_hw *hw) | |||
| 2155 | s32 ret_val; | 2155 | s32 ret_val; |
| 2156 | u32 ctrl; | 2156 | u32 ctrl; |
| 2157 | 2157 | ||
| 2158 | ret_val = phy->ops.check_reset_block(hw); | 2158 | if (phy->ops.check_reset_block) { |
| 2159 | if (ret_val) | 2159 | ret_val = phy->ops.check_reset_block(hw); |
| 2160 | return 0; | 2160 | if (ret_val) |
| 2161 | return 0; | ||
| 2162 | } | ||
| 2161 | 2163 | ||
| 2162 | ret_val = phy->ops.acquire(hw); | 2164 | ret_val = phy->ops.acquire(hw); |
| 2163 | if (ret_val) | 2165 | if (ret_val) |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index bf20457ea23a..17ad6a3c1be1 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | |||
| @@ -1390,6 +1390,8 @@ static void ixgbe_process_skb_fields(struct ixgbe_ring *rx_ring, | |||
| 1390 | union ixgbe_adv_rx_desc *rx_desc, | 1390 | union ixgbe_adv_rx_desc *rx_desc, |
| 1391 | struct sk_buff *skb) | 1391 | struct sk_buff *skb) |
| 1392 | { | 1392 | { |
| 1393 | struct net_device *dev = rx_ring->netdev; | ||
| 1394 | |||
| 1393 | ixgbe_update_rsc_stats(rx_ring, skb); | 1395 | ixgbe_update_rsc_stats(rx_ring, skb); |
| 1394 | 1396 | ||
| 1395 | ixgbe_rx_hash(rx_ring, rx_desc, skb); | 1397 | ixgbe_rx_hash(rx_ring, rx_desc, skb); |
| @@ -1401,14 +1403,15 @@ static void ixgbe_process_skb_fields(struct ixgbe_ring *rx_ring, | |||
| 1401 | ixgbe_ptp_rx_hwtstamp(rx_ring->q_vector, skb); | 1403 | ixgbe_ptp_rx_hwtstamp(rx_ring->q_vector, skb); |
| 1402 | #endif | 1404 | #endif |
| 1403 | 1405 | ||
| 1404 | if (ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_VP)) { | 1406 | if ((dev->features & NETIF_F_HW_VLAN_RX) && |
| 1407 | ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_VP)) { | ||
| 1405 | u16 vid = le16_to_cpu(rx_desc->wb.upper.vlan); | 1408 | u16 vid = le16_to_cpu(rx_desc->wb.upper.vlan); |
| 1406 | __vlan_hwaccel_put_tag(skb, vid); | 1409 | __vlan_hwaccel_put_tag(skb, vid); |
| 1407 | } | 1410 | } |
| 1408 | 1411 | ||
| 1409 | skb_record_rx_queue(skb, rx_ring->queue_index); | 1412 | skb_record_rx_queue(skb, rx_ring->queue_index); |
| 1410 | 1413 | ||
| 1411 | skb->protocol = eth_type_trans(skb, rx_ring->netdev); | 1414 | skb->protocol = eth_type_trans(skb, dev); |
| 1412 | } | 1415 | } |
| 1413 | 1416 | ||
| 1414 | static void ixgbe_rx_skb(struct ixgbe_q_vector *q_vector, | 1417 | static void ixgbe_rx_skb(struct ixgbe_q_vector *q_vector, |
| @@ -3607,10 +3610,6 @@ static void ixgbe_configure_dcb(struct ixgbe_adapter *adapter) | |||
| 3607 | if (hw->mac.type == ixgbe_mac_82598EB) | 3610 | if (hw->mac.type == ixgbe_mac_82598EB) |
| 3608 | netif_set_gso_max_size(adapter->netdev, 32768); | 3611 | netif_set_gso_max_size(adapter->netdev, 32768); |
| 3609 | 3612 | ||
| 3610 | |||
| 3611 | /* Enable VLAN tag insert/strip */ | ||
| 3612 | adapter->netdev->features |= NETIF_F_HW_VLAN_RX; | ||
| 3613 | |||
| 3614 | hw->mac.ops.set_vfta(&adapter->hw, 0, 0, true); | 3613 | hw->mac.ops.set_vfta(&adapter->hw, 0, 0, true); |
| 3615 | 3614 | ||
| 3616 | #ifdef IXGBE_FCOE | 3615 | #ifdef IXGBE_FCOE |
| @@ -6701,11 +6700,6 @@ static netdev_features_t ixgbe_fix_features(struct net_device *netdev, | |||
| 6701 | { | 6700 | { |
| 6702 | struct ixgbe_adapter *adapter = netdev_priv(netdev); | 6701 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 6703 | 6702 | ||
| 6704 | #ifdef CONFIG_DCB | ||
| 6705 | if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) | ||
| 6706 | features &= ~NETIF_F_HW_VLAN_RX; | ||
| 6707 | #endif | ||
| 6708 | |||
| 6709 | /* return error if RXHASH is being enabled when RSS is not supported */ | 6703 | /* return error if RXHASH is being enabled when RSS is not supported */ |
| 6710 | if (!(adapter->flags & IXGBE_FLAG_RSS_ENABLED)) | 6704 | if (!(adapter->flags & IXGBE_FLAG_RSS_ENABLED)) |
| 6711 | features &= ~NETIF_F_RXHASH; | 6705 | features &= ~NETIF_F_RXHASH; |
| @@ -6718,7 +6712,6 @@ static netdev_features_t ixgbe_fix_features(struct net_device *netdev, | |||
| 6718 | if (!(adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE)) | 6712 | if (!(adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE)) |
| 6719 | features &= ~NETIF_F_LRO; | 6713 | features &= ~NETIF_F_LRO; |
| 6720 | 6714 | ||
| 6721 | |||
| 6722 | return features; | 6715 | return features; |
| 6723 | } | 6716 | } |
| 6724 | 6717 | ||
| @@ -6766,6 +6759,11 @@ static int ixgbe_set_features(struct net_device *netdev, | |||
| 6766 | need_reset = true; | 6759 | need_reset = true; |
| 6767 | } | 6760 | } |
| 6768 | 6761 | ||
| 6762 | if (features & NETIF_F_HW_VLAN_RX) | ||
| 6763 | ixgbe_vlan_strip_enable(adapter); | ||
| 6764 | else | ||
| 6765 | ixgbe_vlan_strip_disable(adapter); | ||
| 6766 | |||
| 6769 | if (changed & NETIF_F_RXALL) | 6767 | if (changed & NETIF_F_RXALL) |
| 6770 | need_reset = true; | 6768 | need_reset = true; |
| 6771 | 6769 | ||
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c index 04d901d0ff63..f0f06b2bc28b 100644 --- a/drivers/net/ethernet/marvell/mv643xx_eth.c +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c | |||
| @@ -436,7 +436,9 @@ struct mv643xx_eth_private { | |||
| 436 | /* | 436 | /* |
| 437 | * Hardware-specific parameters. | 437 | * Hardware-specific parameters. |
| 438 | */ | 438 | */ |
| 439 | #if defined(CONFIG_HAVE_CLK) | ||
| 439 | struct clk *clk; | 440 | struct clk *clk; |
| 441 | #endif | ||
| 440 | unsigned int t_clk; | 442 | unsigned int t_clk; |
| 441 | }; | 443 | }; |
| 442 | 444 | ||
| @@ -2895,17 +2897,17 @@ static int mv643xx_eth_probe(struct platform_device *pdev) | |||
| 2895 | mp->dev = dev; | 2897 | mp->dev = dev; |
| 2896 | 2898 | ||
| 2897 | /* | 2899 | /* |
| 2898 | * Get the clk rate, if there is one, otherwise use the default. | 2900 | * Start with a default rate, and if there is a clock, allow |
| 2901 | * it to override the default. | ||
| 2899 | */ | 2902 | */ |
| 2903 | mp->t_clk = 133000000; | ||
| 2904 | #if defined(CONFIG_HAVE_CLK) | ||
| 2900 | mp->clk = clk_get(&pdev->dev, (pdev->id ? "1" : "0")); | 2905 | mp->clk = clk_get(&pdev->dev, (pdev->id ? "1" : "0")); |
| 2901 | if (!IS_ERR(mp->clk)) { | 2906 | if (!IS_ERR(mp->clk)) { |
| 2902 | clk_prepare_enable(mp->clk); | 2907 | clk_prepare_enable(mp->clk); |
| 2903 | mp->t_clk = clk_get_rate(mp->clk); | 2908 | mp->t_clk = clk_get_rate(mp->clk); |
| 2904 | } else { | ||
| 2905 | mp->t_clk = 133000000; | ||
| 2906 | printk(KERN_WARNING "Unable to get clock"); | ||
| 2907 | } | 2909 | } |
| 2908 | 2910 | #endif | |
| 2909 | set_params(mp, pd); | 2911 | set_params(mp, pd); |
| 2910 | netif_set_real_num_tx_queues(dev, mp->txq_count); | 2912 | netif_set_real_num_tx_queues(dev, mp->txq_count); |
| 2911 | netif_set_real_num_rx_queues(dev, mp->rxq_count); | 2913 | netif_set_real_num_rx_queues(dev, mp->rxq_count); |
| @@ -2995,10 +2997,13 @@ static int mv643xx_eth_remove(struct platform_device *pdev) | |||
| 2995 | phy_detach(mp->phy); | 2997 | phy_detach(mp->phy); |
| 2996 | cancel_work_sync(&mp->tx_timeout_task); | 2998 | cancel_work_sync(&mp->tx_timeout_task); |
| 2997 | 2999 | ||
| 3000 | #if defined(CONFIG_HAVE_CLK) | ||
| 2998 | if (!IS_ERR(mp->clk)) { | 3001 | if (!IS_ERR(mp->clk)) { |
| 2999 | clk_disable_unprepare(mp->clk); | 3002 | clk_disable_unprepare(mp->clk); |
| 3000 | clk_put(mp->clk); | 3003 | clk_put(mp->clk); |
| 3001 | } | 3004 | } |
| 3005 | #endif | ||
| 3006 | |||
| 3002 | free_netdev(mp->dev); | 3007 | free_netdev(mp->dev); |
| 3003 | 3008 | ||
| 3004 | platform_set_drvdata(pdev, NULL); | 3009 | platform_set_drvdata(pdev, NULL); |
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c index cace36f2ab92..28a54451a3e5 100644 --- a/drivers/net/ethernet/marvell/sky2.c +++ b/drivers/net/ethernet/marvell/sky2.c | |||
| @@ -4381,10 +4381,12 @@ static int sky2_set_features(struct net_device *dev, netdev_features_t features) | |||
| 4381 | struct sky2_port *sky2 = netdev_priv(dev); | 4381 | struct sky2_port *sky2 = netdev_priv(dev); |
| 4382 | netdev_features_t changed = dev->features ^ features; | 4382 | netdev_features_t changed = dev->features ^ features; |
| 4383 | 4383 | ||
| 4384 | if (changed & NETIF_F_RXCSUM) { | 4384 | if ((changed & NETIF_F_RXCSUM) && |
| 4385 | bool on = features & NETIF_F_RXCSUM; | 4385 | !(sky2->hw->flags & SKY2_HW_NEW_LE)) { |
| 4386 | sky2_write32(sky2->hw, Q_ADDR(rxqaddr[sky2->port], Q_CSR), | 4386 | sky2_write32(sky2->hw, |
| 4387 | on ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM); | 4387 | Q_ADDR(rxqaddr[sky2->port], Q_CSR), |
| 4388 | (features & NETIF_F_RXCSUM) | ||
| 4389 | ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM); | ||
| 4388 | } | 4390 | } |
| 4389 | 4391 | ||
| 4390 | if (changed & NETIF_F_RXHASH) | 4392 | if (changed & NETIF_F_RXHASH) |
diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c index 8d2666fcffd7..083d6715335c 100644 --- a/drivers/net/ethernet/nxp/lpc_eth.c +++ b/drivers/net/ethernet/nxp/lpc_eth.c | |||
| @@ -946,16 +946,16 @@ static void __lpc_handle_xmit(struct net_device *ndev) | |||
| 946 | /* Update stats */ | 946 | /* Update stats */ |
| 947 | ndev->stats.tx_packets++; | 947 | ndev->stats.tx_packets++; |
| 948 | ndev->stats.tx_bytes += skb->len; | 948 | ndev->stats.tx_bytes += skb->len; |
| 949 | |||
| 950 | /* Free buffer */ | ||
| 951 | dev_kfree_skb_irq(skb); | ||
| 952 | } | 949 | } |
| 950 | dev_kfree_skb_irq(skb); | ||
| 953 | 951 | ||
| 954 | txcidx = readl(LPC_ENET_TXCONSUMEINDEX(pldat->net_base)); | 952 | txcidx = readl(LPC_ENET_TXCONSUMEINDEX(pldat->net_base)); |
| 955 | } | 953 | } |
| 956 | 954 | ||
| 957 | if (netif_queue_stopped(ndev)) | 955 | if (pldat->num_used_tx_buffs <= ENET_TX_DESC/2) { |
| 958 | netif_wake_queue(ndev); | 956 | if (netif_queue_stopped(ndev)) |
| 957 | netif_wake_queue(ndev); | ||
| 958 | } | ||
| 959 | } | 959 | } |
| 960 | 960 | ||
| 961 | static int __lpc_handle_recv(struct net_device *ndev, int budget) | 961 | static int __lpc_handle_recv(struct net_device *ndev, int budget) |
| @@ -1320,6 +1320,7 @@ static const struct net_device_ops lpc_netdev_ops = { | |||
| 1320 | .ndo_set_rx_mode = lpc_eth_set_multicast_list, | 1320 | .ndo_set_rx_mode = lpc_eth_set_multicast_list, |
| 1321 | .ndo_do_ioctl = lpc_eth_ioctl, | 1321 | .ndo_do_ioctl = lpc_eth_ioctl, |
| 1322 | .ndo_set_mac_address = lpc_set_mac_address, | 1322 | .ndo_set_mac_address = lpc_set_mac_address, |
| 1323 | .ndo_change_mtu = eth_change_mtu, | ||
| 1323 | }; | 1324 | }; |
| 1324 | 1325 | ||
| 1325 | static int lpc_eth_drv_probe(struct platform_device *pdev) | 1326 | static int lpc_eth_drv_probe(struct platform_device *pdev) |
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 9757ce3543a0..7260aa79466a 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c | |||
| @@ -5889,11 +5889,7 @@ static void rtl_slow_event_work(struct rtl8169_private *tp) | |||
| 5889 | if (status & LinkChg) | 5889 | if (status & LinkChg) |
| 5890 | __rtl8169_check_link_status(dev, tp, tp->mmio_addr, true); | 5890 | __rtl8169_check_link_status(dev, tp, tp->mmio_addr, true); |
| 5891 | 5891 | ||
| 5892 | napi_disable(&tp->napi); | 5892 | rtl_irq_enable_all(tp); |
| 5893 | rtl_irq_disable(tp); | ||
| 5894 | |||
| 5895 | napi_enable(&tp->napi); | ||
| 5896 | napi_schedule(&tp->napi); | ||
| 5897 | } | 5893 | } |
| 5898 | 5894 | ||
| 5899 | static void rtl_task(struct work_struct *work) | 5895 | static void rtl_task(struct work_struct *work) |
diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig index 036428348faa..9f448279e12a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig | |||
| @@ -13,7 +13,7 @@ config STMMAC_ETH | |||
| 13 | if STMMAC_ETH | 13 | if STMMAC_ETH |
| 14 | 14 | ||
| 15 | config STMMAC_PLATFORM | 15 | config STMMAC_PLATFORM |
| 16 | tristate "STMMAC platform bus support" | 16 | bool "STMMAC Platform bus support" |
| 17 | depends on STMMAC_ETH | 17 | depends on STMMAC_ETH |
| 18 | default y | 18 | default y |
| 19 | ---help--- | 19 | ---help--- |
| @@ -26,7 +26,7 @@ config STMMAC_PLATFORM | |||
| 26 | If unsure, say N. | 26 | If unsure, say N. |
| 27 | 27 | ||
| 28 | config STMMAC_PCI | 28 | config STMMAC_PCI |
| 29 | tristate "STMMAC support on PCI bus (EXPERIMENTAL)" | 29 | bool "STMMAC PCI bus support (EXPERIMENTAL)" |
| 30 | depends on STMMAC_ETH && PCI && EXPERIMENTAL | 30 | depends on STMMAC_ETH && PCI && EXPERIMENTAL |
| 31 | ---help--- | 31 | ---help--- |
| 32 | This is to select the Synopsys DWMAC available on PCI devices, | 32 | This is to select the Synopsys DWMAC available on PCI devices, |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index 6b5d060ee9de..dc20c56efc9d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include <linux/clk.h> | 26 | #include <linux/clk.h> |
| 27 | #include <linux/stmmac.h> | 27 | #include <linux/stmmac.h> |
| 28 | #include <linux/phy.h> | 28 | #include <linux/phy.h> |
| 29 | #include <linux/pci.h> | ||
| 29 | #include "common.h" | 30 | #include "common.h" |
| 30 | #ifdef CONFIG_STMMAC_TIMER | 31 | #ifdef CONFIG_STMMAC_TIMER |
| 31 | #include "stmmac_timer.h" | 32 | #include "stmmac_timer.h" |
| @@ -95,7 +96,6 @@ extern int stmmac_mdio_register(struct net_device *ndev); | |||
| 95 | extern void stmmac_set_ethtool_ops(struct net_device *netdev); | 96 | extern void stmmac_set_ethtool_ops(struct net_device *netdev); |
| 96 | extern const struct stmmac_desc_ops enh_desc_ops; | 97 | extern const struct stmmac_desc_ops enh_desc_ops; |
| 97 | extern const struct stmmac_desc_ops ndesc_ops; | 98 | extern const struct stmmac_desc_ops ndesc_ops; |
| 98 | |||
| 99 | int stmmac_freeze(struct net_device *ndev); | 99 | int stmmac_freeze(struct net_device *ndev); |
| 100 | int stmmac_restore(struct net_device *ndev); | 100 | int stmmac_restore(struct net_device *ndev); |
| 101 | int stmmac_resume(struct net_device *ndev); | 101 | int stmmac_resume(struct net_device *ndev); |
| @@ -109,7 +109,7 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device, | |||
| 109 | static inline int stmmac_clk_enable(struct stmmac_priv *priv) | 109 | static inline int stmmac_clk_enable(struct stmmac_priv *priv) |
| 110 | { | 110 | { |
| 111 | if (!IS_ERR(priv->stmmac_clk)) | 111 | if (!IS_ERR(priv->stmmac_clk)) |
| 112 | return clk_enable(priv->stmmac_clk); | 112 | return clk_prepare_enable(priv->stmmac_clk); |
| 113 | 113 | ||
| 114 | return 0; | 114 | return 0; |
| 115 | } | 115 | } |
| @@ -119,7 +119,7 @@ static inline void stmmac_clk_disable(struct stmmac_priv *priv) | |||
| 119 | if (IS_ERR(priv->stmmac_clk)) | 119 | if (IS_ERR(priv->stmmac_clk)) |
| 120 | return; | 120 | return; |
| 121 | 121 | ||
| 122 | clk_disable(priv->stmmac_clk); | 122 | clk_disable_unprepare(priv->stmmac_clk); |
| 123 | } | 123 | } |
| 124 | static inline int stmmac_clk_get(struct stmmac_priv *priv) | 124 | static inline int stmmac_clk_get(struct stmmac_priv *priv) |
| 125 | { | 125 | { |
| @@ -143,3 +143,60 @@ static inline int stmmac_clk_get(struct stmmac_priv *priv) | |||
| 143 | return 0; | 143 | return 0; |
| 144 | } | 144 | } |
| 145 | #endif /* CONFIG_HAVE_CLK */ | 145 | #endif /* CONFIG_HAVE_CLK */ |
| 146 | |||
| 147 | |||
| 148 | #ifdef CONFIG_STMMAC_PLATFORM | ||
| 149 | extern struct platform_driver stmmac_pltfr_driver; | ||
| 150 | static inline int stmmac_register_platform(void) | ||
| 151 | { | ||
| 152 | int err; | ||
| 153 | |||
| 154 | err = platform_driver_register(&stmmac_pltfr_driver); | ||
| 155 | if (err) | ||
| 156 | pr_err("stmmac: failed to register the platform driver\n"); | ||
| 157 | |||
| 158 | return err; | ||
| 159 | } | ||
| 160 | static inline void stmmac_unregister_platform(void) | ||
| 161 | { | ||
| 162 | platform_driver_register(&stmmac_pltfr_driver); | ||
| 163 | } | ||
| 164 | #else | ||
| 165 | static inline int stmmac_register_platform(void) | ||
| 166 | { | ||
| 167 | pr_debug("stmmac: do not register the platf driver\n"); | ||
| 168 | |||
| 169 | return -EINVAL; | ||
| 170 | } | ||
| 171 | static inline void stmmac_unregister_platform(void) | ||
| 172 | { | ||
| 173 | } | ||
| 174 | #endif /* CONFIG_STMMAC_PLATFORM */ | ||
| 175 | |||
| 176 | #ifdef CONFIG_STMMAC_PCI | ||
| 177 | extern struct pci_driver stmmac_pci_driver; | ||
| 178 | static inline int stmmac_register_pci(void) | ||
| 179 | { | ||
| 180 | int err; | ||
| 181 | |||
| 182 | err = pci_register_driver(&stmmac_pci_driver); | ||
| 183 | if (err) | ||
| 184 | pr_err("stmmac: failed to register the PCI driver\n"); | ||
| 185 | |||
| 186 | return err; | ||
| 187 | } | ||
| 188 | static inline void stmmac_unregister_pci(void) | ||
| 189 | { | ||
| 190 | pci_unregister_driver(&stmmac_pci_driver); | ||
| 191 | } | ||
| 192 | #else | ||
| 193 | static inline int stmmac_register_pci(void) | ||
| 194 | { | ||
| 195 | pr_debug("stmmac: do not register the PCI driver\n"); | ||
| 196 | |||
| 197 | return -EINVAL; | ||
| 198 | } | ||
| 199 | static inline void stmmac_unregister_pci(void) | ||
| 200 | { | ||
| 201 | } | ||
| 202 | #endif /* CONFIG_STMMAC_PCI */ | ||
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 70966330f44e..51b3b68528ee 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | |||
| @@ -833,8 +833,9 @@ static u32 stmmac_get_synopsys_id(struct stmmac_priv *priv) | |||
| 833 | 833 | ||
| 834 | /** | 834 | /** |
| 835 | * stmmac_selec_desc_mode | 835 | * stmmac_selec_desc_mode |
| 836 | * @dev : device pointer | 836 | * @priv : private structure |
| 837 | * Description: select the Enhanced/Alternate or Normal descriptors */ | 837 | * Description: select the Enhanced/Alternate or Normal descriptors |
| 838 | */ | ||
| 838 | static void stmmac_selec_desc_mode(struct stmmac_priv *priv) | 839 | static void stmmac_selec_desc_mode(struct stmmac_priv *priv) |
| 839 | { | 840 | { |
| 840 | if (priv->plat->enh_desc) { | 841 | if (priv->plat->enh_desc) { |
| @@ -1861,6 +1862,8 @@ static int stmmac_hw_init(struct stmmac_priv *priv) | |||
| 1861 | /** | 1862 | /** |
| 1862 | * stmmac_dvr_probe | 1863 | * stmmac_dvr_probe |
| 1863 | * @device: device pointer | 1864 | * @device: device pointer |
| 1865 | * @plat_dat: platform data pointer | ||
| 1866 | * @addr: iobase memory address | ||
| 1864 | * Description: this is the main probe function used to | 1867 | * Description: this is the main probe function used to |
| 1865 | * call the alloc_etherdev, allocate the priv structure. | 1868 | * call the alloc_etherdev, allocate the priv structure. |
| 1866 | */ | 1869 | */ |
| @@ -2090,6 +2093,34 @@ int stmmac_restore(struct net_device *ndev) | |||
| 2090 | } | 2093 | } |
| 2091 | #endif /* CONFIG_PM */ | 2094 | #endif /* CONFIG_PM */ |
| 2092 | 2095 | ||
| 2096 | /* Driver can be configured w/ and w/ both PCI and Platf drivers | ||
| 2097 | * depending on the configuration selected. | ||
| 2098 | */ | ||
| 2099 | static int __init stmmac_init(void) | ||
| 2100 | { | ||
| 2101 | int err_plt = 0; | ||
| 2102 | int err_pci = 0; | ||
| 2103 | |||
| 2104 | err_plt = stmmac_register_platform(); | ||
| 2105 | err_pci = stmmac_register_pci(); | ||
| 2106 | |||
| 2107 | if ((err_pci) && (err_plt)) { | ||
| 2108 | pr_err("stmmac: driver registration failed\n"); | ||
| 2109 | return -EINVAL; | ||
| 2110 | } | ||
| 2111 | |||
| 2112 | return 0; | ||
| 2113 | } | ||
| 2114 | |||
| 2115 | static void __exit stmmac_exit(void) | ||
| 2116 | { | ||
| 2117 | stmmac_unregister_platform(); | ||
| 2118 | stmmac_unregister_pci(); | ||
| 2119 | } | ||
| 2120 | |||
| 2121 | module_init(stmmac_init); | ||
| 2122 | module_exit(stmmac_exit); | ||
| 2123 | |||
| 2093 | #ifndef MODULE | 2124 | #ifndef MODULE |
| 2094 | static int __init stmmac_cmdline_opt(char *str) | 2125 | static int __init stmmac_cmdline_opt(char *str) |
| 2095 | { | 2126 | { |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c index 58fab5303e9c..cf826e6b6aa1 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | |||
| @@ -179,7 +179,7 @@ static DEFINE_PCI_DEVICE_TABLE(stmmac_id_table) = { | |||
| 179 | 179 | ||
| 180 | MODULE_DEVICE_TABLE(pci, stmmac_id_table); | 180 | MODULE_DEVICE_TABLE(pci, stmmac_id_table); |
| 181 | 181 | ||
| 182 | static struct pci_driver stmmac_driver = { | 182 | struct pci_driver stmmac_pci_driver = { |
| 183 | .name = STMMAC_RESOURCE_NAME, | 183 | .name = STMMAC_RESOURCE_NAME, |
| 184 | .id_table = stmmac_id_table, | 184 | .id_table = stmmac_id_table, |
| 185 | .probe = stmmac_pci_probe, | 185 | .probe = stmmac_pci_probe, |
| @@ -190,33 +190,6 @@ static struct pci_driver stmmac_driver = { | |||
| 190 | #endif | 190 | #endif |
| 191 | }; | 191 | }; |
| 192 | 192 | ||
| 193 | /** | ||
| 194 | * stmmac_init_module - Entry point for the driver | ||
| 195 | * Description: This function is the entry point for the driver. | ||
| 196 | */ | ||
| 197 | static int __init stmmac_init_module(void) | ||
| 198 | { | ||
| 199 | int ret; | ||
| 200 | |||
| 201 | ret = pci_register_driver(&stmmac_driver); | ||
| 202 | if (ret < 0) | ||
| 203 | pr_err("%s: ERROR: driver registration failed\n", __func__); | ||
| 204 | |||
| 205 | return ret; | ||
| 206 | } | ||
| 207 | |||
| 208 | /** | ||
| 209 | * stmmac_cleanup_module - Cleanup routine for the driver | ||
| 210 | * Description: This function is the cleanup routine for the driver. | ||
| 211 | */ | ||
| 212 | static void __exit stmmac_cleanup_module(void) | ||
| 213 | { | ||
| 214 | pci_unregister_driver(&stmmac_driver); | ||
| 215 | } | ||
| 216 | |||
| 217 | module_init(stmmac_init_module); | ||
| 218 | module_exit(stmmac_cleanup_module); | ||
| 219 | |||
| 220 | MODULE_DESCRIPTION("STMMAC 10/100/1000 Ethernet PCI driver"); | 193 | MODULE_DESCRIPTION("STMMAC 10/100/1000 Ethernet PCI driver"); |
| 221 | MODULE_AUTHOR("Rayagond Kokatanur <rayagond.kokatanur@vayavyalabs.com>"); | 194 | MODULE_AUTHOR("Rayagond Kokatanur <rayagond.kokatanur@vayavyalabs.com>"); |
| 222 | MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>"); | 195 | MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>"); |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 3dd8f0803808..680d2b8dfe27 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | |||
| @@ -255,7 +255,7 @@ static const struct of_device_id stmmac_dt_ids[] = { | |||
| 255 | }; | 255 | }; |
| 256 | MODULE_DEVICE_TABLE(of, stmmac_dt_ids); | 256 | MODULE_DEVICE_TABLE(of, stmmac_dt_ids); |
| 257 | 257 | ||
| 258 | static struct platform_driver stmmac_driver = { | 258 | struct platform_driver stmmac_pltfr_driver = { |
| 259 | .probe = stmmac_pltfr_probe, | 259 | .probe = stmmac_pltfr_probe, |
| 260 | .remove = stmmac_pltfr_remove, | 260 | .remove = stmmac_pltfr_remove, |
| 261 | .driver = { | 261 | .driver = { |
| @@ -266,8 +266,6 @@ static struct platform_driver stmmac_driver = { | |||
| 266 | }, | 266 | }, |
| 267 | }; | 267 | }; |
| 268 | 268 | ||
| 269 | module_platform_driver(stmmac_driver); | ||
| 270 | |||
| 271 | MODULE_DESCRIPTION("STMMAC 10/100/1000 Ethernet PLATFORM driver"); | 269 | MODULE_DESCRIPTION("STMMAC 10/100/1000 Ethernet PLATFORM driver"); |
| 272 | MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>"); | 270 | MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>"); |
| 273 | MODULE_LICENSE("GPL"); | 271 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c index 703c8cce2a2c..8c726b7004d3 100644 --- a/drivers/net/ethernet/sun/niu.c +++ b/drivers/net/ethernet/sun/niu.c | |||
| @@ -3598,7 +3598,6 @@ static int release_tx_packet(struct niu *np, struct tx_ring_info *rp, int idx) | |||
| 3598 | static void niu_tx_work(struct niu *np, struct tx_ring_info *rp) | 3598 | static void niu_tx_work(struct niu *np, struct tx_ring_info *rp) |
| 3599 | { | 3599 | { |
| 3600 | struct netdev_queue *txq; | 3600 | struct netdev_queue *txq; |
| 3601 | unsigned int tx_bytes; | ||
| 3602 | u16 pkt_cnt, tmp; | 3601 | u16 pkt_cnt, tmp; |
| 3603 | int cons, index; | 3602 | int cons, index; |
| 3604 | u64 cs; | 3603 | u64 cs; |
| @@ -3621,18 +3620,12 @@ static void niu_tx_work(struct niu *np, struct tx_ring_info *rp) | |||
| 3621 | netif_printk(np, tx_done, KERN_DEBUG, np->dev, | 3620 | netif_printk(np, tx_done, KERN_DEBUG, np->dev, |
| 3622 | "%s() pkt_cnt[%u] cons[%d]\n", __func__, pkt_cnt, cons); | 3621 | "%s() pkt_cnt[%u] cons[%d]\n", __func__, pkt_cnt, cons); |
| 3623 | 3622 | ||
| 3624 | tx_bytes = 0; | 3623 | while (pkt_cnt--) |
| 3625 | tmp = pkt_cnt; | ||
| 3626 | while (tmp--) { | ||
| 3627 | tx_bytes += rp->tx_buffs[cons].skb->len; | ||
| 3628 | cons = release_tx_packet(np, rp, cons); | 3624 | cons = release_tx_packet(np, rp, cons); |
| 3629 | } | ||
| 3630 | 3625 | ||
| 3631 | rp->cons = cons; | 3626 | rp->cons = cons; |
| 3632 | smp_mb(); | 3627 | smp_mb(); |
| 3633 | 3628 | ||
| 3634 | netdev_tx_completed_queue(txq, pkt_cnt, tx_bytes); | ||
| 3635 | |||
| 3636 | out: | 3629 | out: |
| 3637 | if (unlikely(netif_tx_queue_stopped(txq) && | 3630 | if (unlikely(netif_tx_queue_stopped(txq) && |
| 3638 | (niu_tx_avail(rp) > NIU_TX_WAKEUP_THRESH(rp)))) { | 3631 | (niu_tx_avail(rp) > NIU_TX_WAKEUP_THRESH(rp)))) { |
| @@ -4333,7 +4326,6 @@ static void niu_free_channels(struct niu *np) | |||
| 4333 | struct tx_ring_info *rp = &np->tx_rings[i]; | 4326 | struct tx_ring_info *rp = &np->tx_rings[i]; |
| 4334 | 4327 | ||
| 4335 | niu_free_tx_ring_info(np, rp); | 4328 | niu_free_tx_ring_info(np, rp); |
| 4336 | netdev_tx_reset_queue(netdev_get_tx_queue(np->dev, i)); | ||
| 4337 | } | 4329 | } |
| 4338 | kfree(np->tx_rings); | 4330 | kfree(np->tx_rings); |
| 4339 | np->tx_rings = NULL; | 4331 | np->tx_rings = NULL; |
| @@ -6739,8 +6731,6 @@ static netdev_tx_t niu_start_xmit(struct sk_buff *skb, | |||
| 6739 | prod = NEXT_TX(rp, prod); | 6731 | prod = NEXT_TX(rp, prod); |
| 6740 | } | 6732 | } |
| 6741 | 6733 | ||
| 6742 | netdev_tx_sent_queue(txq, skb->len); | ||
| 6743 | |||
| 6744 | if (prod < rp->prod) | 6734 | if (prod < rp->prod) |
| 6745 | rp->wrap_bit ^= TX_RING_KICK_WRAP; | 6735 | rp->wrap_bit ^= TX_RING_KICK_WRAP; |
| 6746 | rp->prod = prod; | 6736 | rp->prod = prod; |
diff --git a/drivers/net/ethernet/tile/Kconfig b/drivers/net/ethernet/tile/Kconfig index 2d9218f86bca..098b1c42b393 100644 --- a/drivers/net/ethernet/tile/Kconfig +++ b/drivers/net/ethernet/tile/Kconfig | |||
| @@ -7,6 +7,8 @@ config TILE_NET | |||
| 7 | depends on TILE | 7 | depends on TILE |
| 8 | default y | 8 | default y |
| 9 | select CRC32 | 9 | select CRC32 |
| 10 | select TILE_GXIO_MPIPE if TILEGX | ||
| 11 | select HIGH_RES_TIMERS if TILEGX | ||
| 10 | ---help--- | 12 | ---help--- |
| 11 | This is a standard Linux network device driver for the | 13 | This is a standard Linux network device driver for the |
| 12 | on-chip Tilera Gigabit Ethernet and XAUI interfaces. | 14 | on-chip Tilera Gigabit Ethernet and XAUI interfaces. |
diff --git a/drivers/net/ethernet/tile/Makefile b/drivers/net/ethernet/tile/Makefile index f634f142cab4..0ef9eefd3211 100644 --- a/drivers/net/ethernet/tile/Makefile +++ b/drivers/net/ethernet/tile/Makefile | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | obj-$(CONFIG_TILE_NET) += tile_net.o | 5 | obj-$(CONFIG_TILE_NET) += tile_net.o |
| 6 | ifdef CONFIG_TILEGX | 6 | ifdef CONFIG_TILEGX |
| 7 | tile_net-objs := tilegx.o mpipe.o iorpc_mpipe.o dma_queue.o | 7 | tile_net-y := tilegx.o |
| 8 | else | 8 | else |
| 9 | tile_net-objs := tilepro.o | 9 | tile_net-y := tilepro.o |
| 10 | endif | 10 | endif |
diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c new file mode 100644 index 000000000000..83b4b388ad49 --- /dev/null +++ b/drivers/net/ethernet/tile/tilegx.c | |||
| @@ -0,0 +1,1898 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2012 Tilera Corporation. All Rights Reserved. | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or | ||
| 5 | * modify it under the terms of the GNU General Public License | ||
| 6 | * as published by the Free Software Foundation, version 2. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, but | ||
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
| 11 | * NON INFRINGEMENT. See the GNU General Public License for | ||
| 12 | * more details. | ||
| 13 | */ | ||
| 14 | |||
| 15 | #include <linux/module.h> | ||
| 16 | #include <linux/init.h> | ||
| 17 | #include <linux/moduleparam.h> | ||
| 18 | #include <linux/sched.h> | ||
| 19 | #include <linux/kernel.h> /* printk() */ | ||
| 20 | #include <linux/slab.h> /* kmalloc() */ | ||
| 21 | #include <linux/errno.h> /* error codes */ | ||
| 22 | #include <linux/types.h> /* size_t */ | ||
| 23 | #include <linux/interrupt.h> | ||
| 24 | #include <linux/in.h> | ||
| 25 | #include <linux/irq.h> | ||
| 26 | #include <linux/netdevice.h> /* struct device, and other headers */ | ||
| 27 | #include <linux/etherdevice.h> /* eth_type_trans */ | ||
| 28 | #include <linux/skbuff.h> | ||
| 29 | #include <linux/ioctl.h> | ||
| 30 | #include <linux/cdev.h> | ||
| 31 | #include <linux/hugetlb.h> | ||
| 32 | #include <linux/in6.h> | ||
| 33 | #include <linux/timer.h> | ||
| 34 | #include <linux/hrtimer.h> | ||
| 35 | #include <linux/ktime.h> | ||
| 36 | #include <linux/io.h> | ||
| 37 | #include <linux/ctype.h> | ||
| 38 | #include <linux/ip.h> | ||
| 39 | #include <linux/tcp.h> | ||
| 40 | |||
| 41 | #include <asm/checksum.h> | ||
| 42 | #include <asm/homecache.h> | ||
| 43 | #include <gxio/mpipe.h> | ||
| 44 | #include <arch/sim.h> | ||
| 45 | |||
| 46 | /* Default transmit lockup timeout period, in jiffies. */ | ||
| 47 | #define TILE_NET_TIMEOUT (5 * HZ) | ||
| 48 | |||
| 49 | /* The maximum number of distinct channels (idesc.channel is 5 bits). */ | ||
| 50 | #define TILE_NET_CHANNELS 32 | ||
| 51 | |||
| 52 | /* Maximum number of idescs to handle per "poll". */ | ||
| 53 | #define TILE_NET_BATCH 128 | ||
| 54 | |||
| 55 | /* Maximum number of packets to handle per "poll". */ | ||
| 56 | #define TILE_NET_WEIGHT 64 | ||
| 57 | |||
| 58 | /* Number of entries in each iqueue. */ | ||
| 59 | #define IQUEUE_ENTRIES 512 | ||
| 60 | |||
| 61 | /* Number of entries in each equeue. */ | ||
| 62 | #define EQUEUE_ENTRIES 2048 | ||
| 63 | |||
| 64 | /* Total header bytes per equeue slot. Must be big enough for 2 bytes | ||
| 65 | * of NET_IP_ALIGN alignment, plus 14 bytes (?) of L2 header, plus up to | ||
| 66 | * 60 bytes of actual TCP header. We round up to align to cache lines. | ||
| 67 | */ | ||
| 68 | #define HEADER_BYTES 128 | ||
| 69 | |||
| 70 | /* Maximum completions per cpu per device (must be a power of two). | ||
| 71 | * ISSUE: What is the right number here? If this is too small, then | ||
| 72 | * egress might block waiting for free space in a completions array. | ||
| 73 | * ISSUE: At the least, allocate these only for initialized echannels. | ||
| 74 | */ | ||
| 75 | #define TILE_NET_MAX_COMPS 64 | ||
| 76 | |||
| 77 | #define MAX_FRAGS (MAX_SKB_FRAGS + 1) | ||
| 78 | |||
| 79 | /* Size of completions data to allocate. | ||
| 80 | * ISSUE: Probably more than needed since we don't use all the channels. | ||
| 81 | */ | ||
| 82 | #define COMPS_SIZE (TILE_NET_CHANNELS * sizeof(struct tile_net_comps)) | ||
| 83 | |||
| 84 | /* Size of NotifRing data to allocate. */ | ||
| 85 | #define NOTIF_RING_SIZE (IQUEUE_ENTRIES * sizeof(gxio_mpipe_idesc_t)) | ||
| 86 | |||
| 87 | /* Timeout to wake the per-device TX timer after we stop the queue. | ||
| 88 | * We don't want the timeout too short (adds overhead, and might end | ||
| 89 | * up causing stop/wake/stop/wake cycles) or too long (affects performance). | ||
| 90 | * For the 10 Gb NIC, 30 usec means roughly 30+ 1500-byte packets. | ||
| 91 | */ | ||
| 92 | #define TX_TIMER_DELAY_USEC 30 | ||
| 93 | |||
| 94 | /* Timeout to wake the per-cpu egress timer to free completions. */ | ||
| 95 | #define EGRESS_TIMER_DELAY_USEC 1000 | ||
| 96 | |||
| 97 | MODULE_AUTHOR("Tilera Corporation"); | ||
| 98 | MODULE_LICENSE("GPL"); | ||
| 99 | |||
| 100 | /* A "packet fragment" (a chunk of memory). */ | ||
| 101 | struct frag { | ||
| 102 | void *buf; | ||
| 103 | size_t length; | ||
| 104 | }; | ||
| 105 | |||
| 106 | /* A single completion. */ | ||
| 107 | struct tile_net_comp { | ||
| 108 | /* The "complete_count" when the completion will be complete. */ | ||
| 109 | s64 when; | ||
| 110 | /* The buffer to be freed when the completion is complete. */ | ||
| 111 | struct sk_buff *skb; | ||
| 112 | }; | ||
| 113 | |||
| 114 | /* The completions for a given cpu and echannel. */ | ||
| 115 | struct tile_net_comps { | ||
| 116 | /* The completions. */ | ||
| 117 | struct tile_net_comp comp_queue[TILE_NET_MAX_COMPS]; | ||
| 118 | /* The number of completions used. */ | ||
| 119 | unsigned long comp_next; | ||
| 120 | /* The number of completions freed. */ | ||
| 121 | unsigned long comp_last; | ||
| 122 | }; | ||
| 123 | |||
| 124 | /* The transmit wake timer for a given cpu and echannel. */ | ||
| 125 | struct tile_net_tx_wake { | ||
| 126 | struct hrtimer timer; | ||
| 127 | struct net_device *dev; | ||
| 128 | }; | ||
| 129 | |||
| 130 | /* Info for a specific cpu. */ | ||
| 131 | struct tile_net_info { | ||
| 132 | /* The NAPI struct. */ | ||
| 133 | struct napi_struct napi; | ||
| 134 | /* Packet queue. */ | ||
| 135 | gxio_mpipe_iqueue_t iqueue; | ||
| 136 | /* Our cpu. */ | ||
| 137 | int my_cpu; | ||
| 138 | /* True if iqueue is valid. */ | ||
| 139 | bool has_iqueue; | ||
| 140 | /* NAPI flags. */ | ||
| 141 | bool napi_added; | ||
| 142 | bool napi_enabled; | ||
| 143 | /* Number of small sk_buffs which must still be provided. */ | ||
| 144 | unsigned int num_needed_small_buffers; | ||
| 145 | /* Number of large sk_buffs which must still be provided. */ | ||
| 146 | unsigned int num_needed_large_buffers; | ||
| 147 | /* A timer for handling egress completions. */ | ||
| 148 | struct hrtimer egress_timer; | ||
| 149 | /* True if "egress_timer" is scheduled. */ | ||
| 150 | bool egress_timer_scheduled; | ||
| 151 | /* Comps for each egress channel. */ | ||
| 152 | struct tile_net_comps *comps_for_echannel[TILE_NET_CHANNELS]; | ||
| 153 | /* Transmit wake timer for each egress channel. */ | ||
| 154 | struct tile_net_tx_wake tx_wake[TILE_NET_CHANNELS]; | ||
| 155 | }; | ||
| 156 | |||
| 157 | /* Info for egress on a particular egress channel. */ | ||
| 158 | struct tile_net_egress { | ||
| 159 | /* The "equeue". */ | ||
| 160 | gxio_mpipe_equeue_t *equeue; | ||
| 161 | /* The headers for TSO. */ | ||
| 162 | unsigned char *headers; | ||
| 163 | }; | ||
| 164 | |||
| 165 | /* Info for a specific device. */ | ||
| 166 | struct tile_net_priv { | ||
| 167 | /* Our network device. */ | ||
| 168 | struct net_device *dev; | ||
| 169 | /* The primary link. */ | ||
| 170 | gxio_mpipe_link_t link; | ||
| 171 | /* The primary channel, if open, else -1. */ | ||
| 172 | int channel; | ||
| 173 | /* The "loopify" egress link, if needed. */ | ||
| 174 | gxio_mpipe_link_t loopify_link; | ||
| 175 | /* The "loopify" egress channel, if open, else -1. */ | ||
| 176 | int loopify_channel; | ||
| 177 | /* The egress channel (channel or loopify_channel). */ | ||
| 178 | int echannel; | ||
| 179 | /* Total stats. */ | ||
| 180 | struct net_device_stats stats; | ||
| 181 | }; | ||
| 182 | |||
| 183 | /* Egress info, indexed by "priv->echannel" (lazily created as needed). */ | ||
| 184 | static struct tile_net_egress egress_for_echannel[TILE_NET_CHANNELS]; | ||
| 185 | |||
| 186 | /* Devices currently associated with each channel. | ||
| 187 | * NOTE: The array entry can become NULL after ifconfig down, but | ||
| 188 | * we do not free the underlying net_device structures, so it is | ||
| 189 | * safe to use a pointer after reading it from this array. | ||
| 190 | */ | ||
| 191 | static struct net_device *tile_net_devs_for_channel[TILE_NET_CHANNELS]; | ||
| 192 | |||
| 193 | /* A mutex for "tile_net_devs_for_channel". */ | ||
| 194 | static DEFINE_MUTEX(tile_net_devs_for_channel_mutex); | ||
| 195 | |||
| 196 | /* The per-cpu info. */ | ||
| 197 | static DEFINE_PER_CPU(struct tile_net_info, per_cpu_info); | ||
| 198 | |||
| 199 | /* The "context" for all devices. */ | ||
| 200 | static gxio_mpipe_context_t context; | ||
| 201 | |||
| 202 | /* Buffer sizes and mpipe enum codes for buffer stacks. | ||
| 203 | * See arch/tile/include/gxio/mpipe.h for the set of possible values. | ||
| 204 | */ | ||
| 205 | #define BUFFER_SIZE_SMALL_ENUM GXIO_MPIPE_BUFFER_SIZE_128 | ||
| 206 | #define BUFFER_SIZE_SMALL 128 | ||
| 207 | #define BUFFER_SIZE_LARGE_ENUM GXIO_MPIPE_BUFFER_SIZE_1664 | ||
| 208 | #define BUFFER_SIZE_LARGE 1664 | ||
| 209 | |||
| 210 | /* The small/large "buffer stacks". */ | ||
| 211 | static int small_buffer_stack = -1; | ||
| 212 | static int large_buffer_stack = -1; | ||
| 213 | |||
| 214 | /* Amount of memory allocated for each buffer stack. */ | ||
| 215 | static size_t buffer_stack_size; | ||
| 216 | |||
| 217 | /* The actual memory allocated for the buffer stacks. */ | ||
| 218 | static void *small_buffer_stack_va; | ||
| 219 | static void *large_buffer_stack_va; | ||
| 220 | |||
| 221 | /* The buckets. */ | ||
| 222 | static int first_bucket = -1; | ||
| 223 | static int num_buckets = 1; | ||
| 224 | |||
| 225 | /* The ingress irq. */ | ||
| 226 | static int ingress_irq = -1; | ||
| 227 | |||
| 228 | /* Text value of tile_net.cpus if passed as a module parameter. */ | ||
| 229 | static char *network_cpus_string; | ||
| 230 | |||
| 231 | /* The actual cpus in "network_cpus". */ | ||
| 232 | static struct cpumask network_cpus_map; | ||
| 233 | |||
| 234 | /* If "loopify=LINK" was specified, this is "LINK". */ | ||
| 235 | static char *loopify_link_name; | ||
| 236 | |||
| 237 | /* If "tile_net.custom" was specified, this is non-NULL. */ | ||
| 238 | static char *custom_str; | ||
| 239 | |||
| 240 | /* The "tile_net.cpus" argument specifies the cpus that are dedicated | ||
| 241 | * to handle ingress packets. | ||
| 242 | * | ||
| 243 | * The parameter should be in the form "tile_net.cpus=m-n[,x-y]", where | ||
| 244 | * m, n, x, y are integer numbers that represent the cpus that can be | ||
| 245 | * neither a dedicated cpu nor a dataplane cpu. | ||
| 246 | */ | ||
| 247 | static bool network_cpus_init(void) | ||
| 248 | { | ||
| 249 | char buf[1024]; | ||
| 250 | int rc; | ||
| 251 | |||
| 252 | if (network_cpus_string == NULL) | ||
| 253 | return false; | ||
| 254 | |||
| 255 | rc = cpulist_parse_crop(network_cpus_string, &network_cpus_map); | ||
| 256 | if (rc != 0) { | ||
| 257 | pr_warn("tile_net.cpus=%s: malformed cpu list\n", | ||
| 258 | network_cpus_string); | ||
| 259 | return false; | ||
| 260 | } | ||
| 261 | |||
| 262 | /* Remove dedicated cpus. */ | ||
| 263 | cpumask_and(&network_cpus_map, &network_cpus_map, cpu_possible_mask); | ||
| 264 | |||
| 265 | if (cpumask_empty(&network_cpus_map)) { | ||
| 266 | pr_warn("Ignoring empty tile_net.cpus='%s'.\n", | ||
| 267 | network_cpus_string); | ||
| 268 | return false; | ||
| 269 | } | ||
| 270 | |||
| 271 | cpulist_scnprintf(buf, sizeof(buf), &network_cpus_map); | ||
| 272 | pr_info("Linux network CPUs: %s\n", buf); | ||
| 273 | return true; | ||
| 274 | } | ||
| 275 | |||
| 276 | module_param_named(cpus, network_cpus_string, charp, 0444); | ||
| 277 | MODULE_PARM_DESC(cpus, "cpulist of cores that handle network interrupts"); | ||
| 278 | |||
| 279 | /* The "tile_net.loopify=LINK" argument causes the named device to | ||
| 280 | * actually use "loop0" for ingress, and "loop1" for egress. This | ||
| 281 | * allows an app to sit between the actual link and linux, passing | ||
| 282 | * (some) packets along to linux, and forwarding (some) packets sent | ||
| 283 | * out by linux. | ||
| 284 | */ | ||
| 285 | module_param_named(loopify, loopify_link_name, charp, 0444); | ||
| 286 | MODULE_PARM_DESC(loopify, "name the device to use loop0/1 for ingress/egress"); | ||
| 287 | |||
| 288 | /* The "tile_net.custom" argument causes us to ignore the "conventional" | ||
| 289 | * classifier metadata, in particular, the "l2_offset". | ||
| 290 | */ | ||
| 291 | module_param_named(custom, custom_str, charp, 0444); | ||
| 292 | MODULE_PARM_DESC(custom, "indicates a (heavily) customized classifier"); | ||
| 293 | |||
| 294 | /* Atomically update a statistics field. | ||
| 295 | * Note that on TILE-Gx, this operation is fire-and-forget on the | ||
| 296 | * issuing core (single-cycle dispatch) and takes only a few cycles | ||
| 297 | * longer than a regular store when the request reaches the home cache. | ||
| 298 | * No expensive bus management overhead is required. | ||
| 299 | */ | ||
| 300 | static void tile_net_stats_add(unsigned long value, unsigned long *field) | ||
| 301 | { | ||
| 302 | BUILD_BUG_ON(sizeof(atomic_long_t) != sizeof(unsigned long)); | ||
| 303 | atomic_long_add(value, (atomic_long_t *)field); | ||
| 304 | } | ||
| 305 | |||
| 306 | /* Allocate and push a buffer. */ | ||
| 307 | static bool tile_net_provide_buffer(bool small) | ||
| 308 | { | ||
| 309 | int stack = small ? small_buffer_stack : large_buffer_stack; | ||
| 310 | const unsigned long buffer_alignment = 128; | ||
| 311 | struct sk_buff *skb; | ||
| 312 | int len; | ||
| 313 | |||
| 314 | len = sizeof(struct sk_buff **) + buffer_alignment; | ||
| 315 | len += (small ? BUFFER_SIZE_SMALL : BUFFER_SIZE_LARGE); | ||
| 316 | skb = dev_alloc_skb(len); | ||
| 317 | if (skb == NULL) | ||
| 318 | return false; | ||
| 319 | |||
| 320 | /* Make room for a back-pointer to 'skb' and guarantee alignment. */ | ||
| 321 | skb_reserve(skb, sizeof(struct sk_buff **)); | ||
| 322 | skb_reserve(skb, -(long)skb->data & (buffer_alignment - 1)); | ||
| 323 | |||
| 324 | /* Save a back-pointer to 'skb'. */ | ||
| 325 | *(struct sk_buff **)(skb->data - sizeof(struct sk_buff **)) = skb; | ||
| 326 | |||
| 327 | /* Make sure "skb" and the back-pointer have been flushed. */ | ||
| 328 | wmb(); | ||
| 329 | |||
| 330 | gxio_mpipe_push_buffer(&context, stack, | ||
| 331 | (void *)va_to_tile_io_addr(skb->data)); | ||
| 332 | |||
| 333 | return true; | ||
| 334 | } | ||
| 335 | |||
| 336 | /* Convert a raw mpipe buffer to its matching skb pointer. */ | ||
| 337 | static struct sk_buff *mpipe_buf_to_skb(void *va) | ||
| 338 | { | ||
| 339 | /* Acquire the associated "skb". */ | ||
| 340 | struct sk_buff **skb_ptr = va - sizeof(*skb_ptr); | ||
| 341 | struct sk_buff *skb = *skb_ptr; | ||
| 342 | |||
| 343 | /* Paranoia. */ | ||
| 344 | if (skb->data != va) { | ||
| 345 | /* Panic here since there's a reasonable chance | ||
| 346 | * that corrupt buffers means generic memory | ||
| 347 | * corruption, with unpredictable system effects. | ||
| 348 | */ | ||
| 349 | panic("Corrupt linux buffer! va=%p, skb=%p, skb->data=%p", | ||
| 350 | va, skb, skb->data); | ||
| 351 | } | ||
| 352 | |||
| 353 | return skb; | ||
| 354 | } | ||
| 355 | |||
| 356 | static void tile_net_pop_all_buffers(int stack) | ||
| 357 | { | ||
| 358 | for (;;) { | ||
| 359 | tile_io_addr_t addr = | ||
| 360 | (tile_io_addr_t)gxio_mpipe_pop_buffer(&context, stack); | ||
| 361 | if (addr == 0) | ||
| 362 | break; | ||
| 363 | dev_kfree_skb_irq(mpipe_buf_to_skb(tile_io_addr_to_va(addr))); | ||
| 364 | } | ||
| 365 | } | ||
| 366 | |||
| 367 | /* Provide linux buffers to mPIPE. */ | ||
| 368 | static void tile_net_provide_needed_buffers(void) | ||
| 369 | { | ||
| 370 | struct tile_net_info *info = &__get_cpu_var(per_cpu_info); | ||
| 371 | |||
| 372 | while (info->num_needed_small_buffers != 0) { | ||
| 373 | if (!tile_net_provide_buffer(true)) | ||
| 374 | goto oops; | ||
| 375 | info->num_needed_small_buffers--; | ||
| 376 | } | ||
| 377 | |||
| 378 | while (info->num_needed_large_buffers != 0) { | ||
| 379 | if (!tile_net_provide_buffer(false)) | ||
| 380 | goto oops; | ||
| 381 | info->num_needed_large_buffers--; | ||
| 382 | } | ||
| 383 | |||
| 384 | return; | ||
| 385 | |||
| 386 | oops: | ||
| 387 | /* Add a description to the page allocation failure dump. */ | ||
| 388 | pr_notice("Tile %d still needs some buffers\n", info->my_cpu); | ||
| 389 | } | ||
| 390 | |||
| 391 | static inline bool filter_packet(struct net_device *dev, void *buf) | ||
| 392 | { | ||
| 393 | /* Filter packets received before we're up. */ | ||
| 394 | if (dev == NULL || !(dev->flags & IFF_UP)) | ||
| 395 | return true; | ||
| 396 | |||
| 397 | /* Filter out packets that aren't for us. */ | ||
| 398 | if (!(dev->flags & IFF_PROMISC) && | ||
| 399 | !is_multicast_ether_addr(buf) && | ||
| 400 | compare_ether_addr(dev->dev_addr, buf) != 0) | ||
| 401 | return true; | ||
| 402 | |||
| 403 | return false; | ||
| 404 | } | ||
| 405 | |||
| 406 | static void tile_net_receive_skb(struct net_device *dev, struct sk_buff *skb, | ||
| 407 | gxio_mpipe_idesc_t *idesc, unsigned long len) | ||
| 408 | { | ||
| 409 | struct tile_net_info *info = &__get_cpu_var(per_cpu_info); | ||
| 410 | struct tile_net_priv *priv = netdev_priv(dev); | ||
| 411 | |||
| 412 | /* Encode the actual packet length. */ | ||
| 413 | skb_put(skb, len); | ||
| 414 | |||
| 415 | skb->protocol = eth_type_trans(skb, dev); | ||
| 416 | |||
| 417 | /* Acknowledge "good" hardware checksums. */ | ||
| 418 | if (idesc->cs && idesc->csum_seed_val == 0xFFFF) | ||
| 419 | skb->ip_summed = CHECKSUM_UNNECESSARY; | ||
| 420 | |||
| 421 | netif_receive_skb(skb); | ||
| 422 | |||
| 423 | /* Update stats. */ | ||
| 424 | tile_net_stats_add(1, &priv->stats.rx_packets); | ||
| 425 | tile_net_stats_add(len, &priv->stats.rx_bytes); | ||
| 426 | |||
| 427 | /* Need a new buffer. */ | ||
| 428 | if (idesc->size == BUFFER_SIZE_SMALL_ENUM) | ||
| 429 | info->num_needed_small_buffers++; | ||
| 430 | else | ||
| 431 | info->num_needed_large_buffers++; | ||
| 432 | } | ||
| 433 | |||
| 434 | /* Handle a packet. Return true if "processed", false if "filtered". */ | ||
| 435 | static bool tile_net_handle_packet(gxio_mpipe_idesc_t *idesc) | ||
| 436 | { | ||
| 437 | struct tile_net_info *info = &__get_cpu_var(per_cpu_info); | ||
| 438 | struct net_device *dev = tile_net_devs_for_channel[idesc->channel]; | ||
| 439 | uint8_t l2_offset; | ||
| 440 | void *va; | ||
| 441 | void *buf; | ||
| 442 | unsigned long len; | ||
| 443 | bool filter; | ||
| 444 | |||
| 445 | /* Drop packets for which no buffer was available. | ||
| 446 | * NOTE: This happens under heavy load. | ||
| 447 | */ | ||
| 448 | if (idesc->be) { | ||
| 449 | struct tile_net_priv *priv = netdev_priv(dev); | ||
| 450 | tile_net_stats_add(1, &priv->stats.rx_dropped); | ||
| 451 | gxio_mpipe_iqueue_consume(&info->iqueue, idesc); | ||
| 452 | if (net_ratelimit()) | ||
| 453 | pr_info("Dropping packet (insufficient buffers).\n"); | ||
| 454 | return false; | ||
| 455 | } | ||
| 456 | |||
| 457 | /* Get the "l2_offset", if allowed. */ | ||
| 458 | l2_offset = custom_str ? 0 : gxio_mpipe_idesc_get_l2_offset(idesc); | ||
| 459 | |||
| 460 | /* Get the raw buffer VA (includes "headroom"). */ | ||
| 461 | va = tile_io_addr_to_va((unsigned long)(long)idesc->va); | ||
| 462 | |||
| 463 | /* Get the actual packet start/length. */ | ||
| 464 | buf = va + l2_offset; | ||
| 465 | len = idesc->l2_size - l2_offset; | ||
| 466 | |||
| 467 | /* Point "va" at the raw buffer. */ | ||
| 468 | va -= NET_IP_ALIGN; | ||
| 469 | |||
| 470 | filter = filter_packet(dev, buf); | ||
| 471 | if (filter) { | ||
| 472 | gxio_mpipe_iqueue_drop(&info->iqueue, idesc); | ||
| 473 | } else { | ||
| 474 | struct sk_buff *skb = mpipe_buf_to_skb(va); | ||
| 475 | |||
| 476 | /* Skip headroom, and any custom header. */ | ||
| 477 | skb_reserve(skb, NET_IP_ALIGN + l2_offset); | ||
| 478 | |||
| 479 | tile_net_receive_skb(dev, skb, idesc, len); | ||
| 480 | } | ||
| 481 | |||
| 482 | gxio_mpipe_iqueue_consume(&info->iqueue, idesc); | ||
| 483 | return !filter; | ||
| 484 | } | ||
| 485 | |||
| 486 | /* Handle some packets for the current CPU. | ||
| 487 | * | ||
| 488 | * This function handles up to TILE_NET_BATCH idescs per call. | ||
| 489 | * | ||
| 490 | * ISSUE: Since we do not provide new buffers until this function is | ||
| 491 | * complete, we must initially provide enough buffers for each network | ||
| 492 | * cpu to fill its iqueue and also its batched idescs. | ||
| 493 | * | ||
| 494 | * ISSUE: The "rotting packet" race condition occurs if a packet | ||
| 495 | * arrives after the queue appears to be empty, and before the | ||
| 496 | * hypervisor interrupt is re-enabled. | ||
| 497 | */ | ||
| 498 | static int tile_net_poll(struct napi_struct *napi, int budget) | ||
| 499 | { | ||
| 500 | struct tile_net_info *info = &__get_cpu_var(per_cpu_info); | ||
| 501 | unsigned int work = 0; | ||
| 502 | gxio_mpipe_idesc_t *idesc; | ||
| 503 | int i, n; | ||
| 504 | |||
| 505 | /* Process packets. */ | ||
| 506 | while ((n = gxio_mpipe_iqueue_try_peek(&info->iqueue, &idesc)) > 0) { | ||
| 507 | for (i = 0; i < n; i++) { | ||
| 508 | if (i == TILE_NET_BATCH) | ||
| 509 | goto done; | ||
| 510 | if (tile_net_handle_packet(idesc + i)) { | ||
| 511 | if (++work >= budget) | ||
| 512 | goto done; | ||
| 513 | } | ||
| 514 | } | ||
| 515 | } | ||
| 516 | |||
| 517 | /* There are no packets left. */ | ||
| 518 | napi_complete(&info->napi); | ||
| 519 | |||
| 520 | /* Re-enable hypervisor interrupts. */ | ||
| 521 | gxio_mpipe_enable_notif_ring_interrupt(&context, info->iqueue.ring); | ||
| 522 | |||
| 523 | /* HACK: Avoid the "rotting packet" problem. */ | ||
| 524 | if (gxio_mpipe_iqueue_try_peek(&info->iqueue, &idesc) > 0) | ||
| 525 | napi_schedule(&info->napi); | ||
| 526 | |||
| 527 | /* ISSUE: Handle completions? */ | ||
| 528 | |||
| 529 | done: | ||
| 530 | tile_net_provide_needed_buffers(); | ||
| 531 | |||
| 532 | return work; | ||
| 533 | } | ||
| 534 | |||
| 535 | /* Handle an ingress interrupt on the current cpu. */ | ||
| 536 | static irqreturn_t tile_net_handle_ingress_irq(int irq, void *unused) | ||
| 537 | { | ||
| 538 | struct tile_net_info *info = &__get_cpu_var(per_cpu_info); | ||
| 539 | napi_schedule(&info->napi); | ||
| 540 | return IRQ_HANDLED; | ||
| 541 | } | ||
| 542 | |||
| 543 | /* Free some completions. This must be called with interrupts blocked. */ | ||
| 544 | static int tile_net_free_comps(gxio_mpipe_equeue_t *equeue, | ||
| 545 | struct tile_net_comps *comps, | ||
| 546 | int limit, bool force_update) | ||
| 547 | { | ||
| 548 | int n = 0; | ||
| 549 | while (comps->comp_last < comps->comp_next) { | ||
| 550 | unsigned int cid = comps->comp_last % TILE_NET_MAX_COMPS; | ||
| 551 | struct tile_net_comp *comp = &comps->comp_queue[cid]; | ||
| 552 | if (!gxio_mpipe_equeue_is_complete(equeue, comp->when, | ||
| 553 | force_update || n == 0)) | ||
| 554 | break; | ||
| 555 | dev_kfree_skb_irq(comp->skb); | ||
| 556 | comps->comp_last++; | ||
| 557 | if (++n == limit) | ||
| 558 | break; | ||
| 559 | } | ||
| 560 | return n; | ||
| 561 | } | ||
| 562 | |||
| 563 | /* Add a completion. This must be called with interrupts blocked. | ||
| 564 | * tile_net_equeue_try_reserve() will have ensured a free completion entry. | ||
| 565 | */ | ||
| 566 | static void add_comp(gxio_mpipe_equeue_t *equeue, | ||
| 567 | struct tile_net_comps *comps, | ||
| 568 | uint64_t when, struct sk_buff *skb) | ||
| 569 | { | ||
| 570 | int cid = comps->comp_next % TILE_NET_MAX_COMPS; | ||
| 571 | comps->comp_queue[cid].when = when; | ||
| 572 | comps->comp_queue[cid].skb = skb; | ||
| 573 | comps->comp_next++; | ||
| 574 | } | ||
| 575 | |||
| 576 | static void tile_net_schedule_tx_wake_timer(struct net_device *dev) | ||
| 577 | { | ||
| 578 | struct tile_net_info *info = &__get_cpu_var(per_cpu_info); | ||
| 579 | struct tile_net_priv *priv = netdev_priv(dev); | ||
| 580 | |||
| 581 | hrtimer_start(&info->tx_wake[priv->echannel].timer, | ||
| 582 | ktime_set(0, TX_TIMER_DELAY_USEC * 1000UL), | ||
| 583 | HRTIMER_MODE_REL_PINNED); | ||
| 584 | } | ||
| 585 | |||
| 586 | static enum hrtimer_restart tile_net_handle_tx_wake_timer(struct hrtimer *t) | ||
| 587 | { | ||
| 588 | struct tile_net_tx_wake *tx_wake = | ||
| 589 | container_of(t, struct tile_net_tx_wake, timer); | ||
| 590 | netif_wake_subqueue(tx_wake->dev, smp_processor_id()); | ||
| 591 | return HRTIMER_NORESTART; | ||
| 592 | } | ||
| 593 | |||
| 594 | /* Make sure the egress timer is scheduled. */ | ||
| 595 | static void tile_net_schedule_egress_timer(void) | ||
| 596 | { | ||
| 597 | struct tile_net_info *info = &__get_cpu_var(per_cpu_info); | ||
| 598 | |||
| 599 | if (!info->egress_timer_scheduled) { | ||
| 600 | hrtimer_start(&info->egress_timer, | ||
| 601 | ktime_set(0, EGRESS_TIMER_DELAY_USEC * 1000UL), | ||
| 602 | HRTIMER_MODE_REL_PINNED); | ||
| 603 | info->egress_timer_scheduled = true; | ||
| 604 | } | ||
| 605 | } | ||
| 606 | |||
| 607 | /* The "function" for "info->egress_timer". | ||
| 608 | * | ||
| 609 | * This timer will reschedule itself as long as there are any pending | ||
| 610 | * completions expected for this tile. | ||
| 611 | */ | ||
| 612 | static enum hrtimer_restart tile_net_handle_egress_timer(struct hrtimer *t) | ||
| 613 | { | ||
| 614 | struct tile_net_info *info = &__get_cpu_var(per_cpu_info); | ||
| 615 | unsigned long irqflags; | ||
| 616 | bool pending = false; | ||
| 617 | int i; | ||
| 618 | |||
| 619 | local_irq_save(irqflags); | ||
| 620 | |||
| 621 | /* The timer is no longer scheduled. */ | ||
| 622 | info->egress_timer_scheduled = false; | ||
| 623 | |||
| 624 | /* Free all possible comps for this tile. */ | ||
| 625 | for (i = 0; i < TILE_NET_CHANNELS; i++) { | ||
| 626 | struct tile_net_egress *egress = &egress_for_echannel[i]; | ||
| 627 | struct tile_net_comps *comps = info->comps_for_echannel[i]; | ||
| 628 | if (comps->comp_last >= comps->comp_next) | ||
| 629 | continue; | ||
| 630 | tile_net_free_comps(egress->equeue, comps, -1, true); | ||
| 631 | pending = pending || (comps->comp_last < comps->comp_next); | ||
| 632 | } | ||
| 633 | |||
| 634 | /* Reschedule timer if needed. */ | ||
| 635 | if (pending) | ||
| 636 | tile_net_schedule_egress_timer(); | ||
| 637 | |||
| 638 | local_irq_restore(irqflags); | ||
| 639 | |||
| 640 | return HRTIMER_NORESTART; | ||
| 641 | } | ||
| 642 | |||
| 643 | /* Helper function for "tile_net_update()". | ||
| 644 | * "dev" (i.e. arg) is the device being brought up or down, | ||
| 645 | * or NULL if all devices are now down. | ||
| 646 | */ | ||
| 647 | static void tile_net_update_cpu(void *arg) | ||
| 648 | { | ||
| 649 | struct tile_net_info *info = &__get_cpu_var(per_cpu_info); | ||
| 650 | struct net_device *dev = arg; | ||
| 651 | |||
| 652 | if (!info->has_iqueue) | ||
| 653 | return; | ||
| 654 | |||
| 655 | if (dev != NULL) { | ||
| 656 | if (!info->napi_added) { | ||
| 657 | netif_napi_add(dev, &info->napi, | ||
| 658 | tile_net_poll, TILE_NET_WEIGHT); | ||
| 659 | info->napi_added = true; | ||
| 660 | } | ||
| 661 | if (!info->napi_enabled) { | ||
| 662 | napi_enable(&info->napi); | ||
| 663 | info->napi_enabled = true; | ||
| 664 | } | ||
| 665 | enable_percpu_irq(ingress_irq, 0); | ||
| 666 | } else { | ||
| 667 | disable_percpu_irq(ingress_irq); | ||
| 668 | if (info->napi_enabled) { | ||
| 669 | napi_disable(&info->napi); | ||
| 670 | info->napi_enabled = false; | ||
| 671 | } | ||
| 672 | /* FIXME: Drain the iqueue. */ | ||
| 673 | } | ||
| 674 | } | ||
| 675 | |||
| 676 | /* Helper function for tile_net_open() and tile_net_stop(). | ||
| 677 | * Always called under tile_net_devs_for_channel_mutex. | ||
| 678 | */ | ||
| 679 | static int tile_net_update(struct net_device *dev) | ||
| 680 | { | ||
| 681 | static gxio_mpipe_rules_t rules; /* too big to fit on the stack */ | ||
| 682 | bool saw_channel = false; | ||
| 683 | int channel; | ||
| 684 | int rc; | ||
| 685 | int cpu; | ||
| 686 | |||
| 687 | gxio_mpipe_rules_init(&rules, &context); | ||
| 688 | |||
| 689 | for (channel = 0; channel < TILE_NET_CHANNELS; channel++) { | ||
| 690 | if (tile_net_devs_for_channel[channel] == NULL) | ||
| 691 | continue; | ||
| 692 | if (!saw_channel) { | ||
| 693 | saw_channel = true; | ||
| 694 | gxio_mpipe_rules_begin(&rules, first_bucket, | ||
| 695 | num_buckets, NULL); | ||
| 696 | gxio_mpipe_rules_set_headroom(&rules, NET_IP_ALIGN); | ||
| 697 | } | ||
| 698 | gxio_mpipe_rules_add_channel(&rules, channel); | ||
| 699 | } | ||
| 700 | |||
| 701 | /* NOTE: This can fail if there is no classifier. | ||
| 702 | * ISSUE: Can anything else cause it to fail? | ||
| 703 | */ | ||
| 704 | rc = gxio_mpipe_rules_commit(&rules); | ||
| 705 | if (rc != 0) { | ||
| 706 | netdev_warn(dev, "gxio_mpipe_rules_commit failed: %d\n", rc); | ||
| 707 | return -EIO; | ||
| 708 | } | ||
| 709 | |||
| 710 | /* Update all cpus, sequentially (to protect "netif_napi_add()"). */ | ||
| 711 | for_each_online_cpu(cpu) | ||
| 712 | smp_call_function_single(cpu, tile_net_update_cpu, | ||
| 713 | (saw_channel ? dev : NULL), 1); | ||
| 714 | |||
| 715 | /* HACK: Allow packets to flow in the simulator. */ | ||
| 716 | if (saw_channel) | ||
| 717 | sim_enable_mpipe_links(0, -1); | ||
| 718 | |||
| 719 | return 0; | ||
| 720 | } | ||
| 721 | |||
| 722 | /* Allocate and initialize mpipe buffer stacks, and register them in | ||
| 723 | * the mPIPE TLBs, for both small and large packet sizes. | ||
| 724 | * This routine supports tile_net_init_mpipe(), below. | ||
| 725 | */ | ||
| 726 | static int init_buffer_stacks(struct net_device *dev, int num_buffers) | ||
| 727 | { | ||
| 728 | pte_t hash_pte = pte_set_home((pte_t) { 0 }, PAGE_HOME_HASH); | ||
| 729 | int rc; | ||
| 730 | |||
| 731 | /* Compute stack bytes; we round up to 64KB and then use | ||
| 732 | * alloc_pages() so we get the required 64KB alignment as well. | ||
| 733 | */ | ||
| 734 | buffer_stack_size = | ||
| 735 | ALIGN(gxio_mpipe_calc_buffer_stack_bytes(num_buffers), | ||
| 736 | 64 * 1024); | ||
| 737 | |||
| 738 | /* Allocate two buffer stack indices. */ | ||
| 739 | rc = gxio_mpipe_alloc_buffer_stacks(&context, 2, 0, 0); | ||
| 740 | if (rc < 0) { | ||
| 741 | netdev_err(dev, "gxio_mpipe_alloc_buffer_stacks failed: %d\n", | ||
| 742 | rc); | ||
| 743 | return rc; | ||
| 744 | } | ||
| 745 | small_buffer_stack = rc; | ||
| 746 | large_buffer_stack = rc + 1; | ||
| 747 | |||
| 748 | /* Allocate the small memory stack. */ | ||
| 749 | small_buffer_stack_va = | ||
| 750 | alloc_pages_exact(buffer_stack_size, GFP_KERNEL); | ||
| 751 | if (small_buffer_stack_va == NULL) { | ||
| 752 | netdev_err(dev, | ||
| 753 | "Could not alloc %zd bytes for buffer stacks\n", | ||
| 754 | buffer_stack_size); | ||
| 755 | return -ENOMEM; | ||
| 756 | } | ||
| 757 | rc = gxio_mpipe_init_buffer_stack(&context, small_buffer_stack, | ||
| 758 | BUFFER_SIZE_SMALL_ENUM, | ||
| 759 | small_buffer_stack_va, | ||
| 760 | buffer_stack_size, 0); | ||
| 761 | if (rc != 0) { | ||
| 762 | netdev_err(dev, "gxio_mpipe_init_buffer_stack: %d\n", rc); | ||
| 763 | return rc; | ||
| 764 | } | ||
| 765 | rc = gxio_mpipe_register_client_memory(&context, small_buffer_stack, | ||
| 766 | hash_pte, 0); | ||
| 767 | if (rc != 0) { | ||
| 768 | netdev_err(dev, | ||
| 769 | "gxio_mpipe_register_buffer_memory failed: %d\n", | ||
| 770 | rc); | ||
| 771 | return rc; | ||
| 772 | } | ||
| 773 | |||
| 774 | /* Allocate the large buffer stack. */ | ||
| 775 | large_buffer_stack_va = | ||
| 776 | alloc_pages_exact(buffer_stack_size, GFP_KERNEL); | ||
| 777 | if (large_buffer_stack_va == NULL) { | ||
| 778 | netdev_err(dev, | ||
| 779 | "Could not alloc %zd bytes for buffer stacks\n", | ||
| 780 | buffer_stack_size); | ||
| 781 | return -ENOMEM; | ||
| 782 | } | ||
| 783 | rc = gxio_mpipe_init_buffer_stack(&context, large_buffer_stack, | ||
| 784 | BUFFER_SIZE_LARGE_ENUM, | ||
| 785 | large_buffer_stack_va, | ||
| 786 | buffer_stack_size, 0); | ||
| 787 | if (rc != 0) { | ||
| 788 | netdev_err(dev, "gxio_mpipe_init_buffer_stack failed: %d\n", | ||
| 789 | rc); | ||
| 790 | return rc; | ||
| 791 | } | ||
| 792 | rc = gxio_mpipe_register_client_memory(&context, large_buffer_stack, | ||
| 793 | hash_pte, 0); | ||
| 794 | if (rc != 0) { | ||
| 795 | netdev_err(dev, | ||
| 796 | "gxio_mpipe_register_buffer_memory failed: %d\n", | ||
| 797 | rc); | ||
| 798 | return rc; | ||
| 799 | } | ||
| 800 | |||
| 801 | return 0; | ||
| 802 | } | ||
| 803 | |||
| 804 | /* Allocate per-cpu resources (memory for completions and idescs). | ||
| 805 | * This routine supports tile_net_init_mpipe(), below. | ||
| 806 | */ | ||
| 807 | static int alloc_percpu_mpipe_resources(struct net_device *dev, | ||
| 808 | int cpu, int ring) | ||
| 809 | { | ||
| 810 | struct tile_net_info *info = &per_cpu(per_cpu_info, cpu); | ||
| 811 | int order, i, rc; | ||
| 812 | struct page *page; | ||
| 813 | void *addr; | ||
| 814 | |||
| 815 | /* Allocate the "comps". */ | ||
| 816 | order = get_order(COMPS_SIZE); | ||
| 817 | page = homecache_alloc_pages(GFP_KERNEL, order, cpu); | ||
| 818 | if (page == NULL) { | ||
| 819 | netdev_err(dev, "Failed to alloc %zd bytes comps memory\n", | ||
| 820 | COMPS_SIZE); | ||
| 821 | return -ENOMEM; | ||
| 822 | } | ||
| 823 | addr = pfn_to_kaddr(page_to_pfn(page)); | ||
| 824 | memset(addr, 0, COMPS_SIZE); | ||
| 825 | for (i = 0; i < TILE_NET_CHANNELS; i++) | ||
| 826 | info->comps_for_echannel[i] = | ||
| 827 | addr + i * sizeof(struct tile_net_comps); | ||
| 828 | |||
| 829 | /* If this is a network cpu, create an iqueue. */ | ||
| 830 | if (cpu_isset(cpu, network_cpus_map)) { | ||
| 831 | order = get_order(NOTIF_RING_SIZE); | ||
| 832 | page = homecache_alloc_pages(GFP_KERNEL, order, cpu); | ||
| 833 | if (page == NULL) { | ||
| 834 | netdev_err(dev, | ||
| 835 | "Failed to alloc %zd bytes iqueue memory\n", | ||
| 836 | NOTIF_RING_SIZE); | ||
| 837 | return -ENOMEM; | ||
| 838 | } | ||
| 839 | addr = pfn_to_kaddr(page_to_pfn(page)); | ||
| 840 | rc = gxio_mpipe_iqueue_init(&info->iqueue, &context, ring++, | ||
| 841 | addr, NOTIF_RING_SIZE, 0); | ||
| 842 | if (rc < 0) { | ||
| 843 | netdev_err(dev, | ||
| 844 | "gxio_mpipe_iqueue_init failed: %d\n", rc); | ||
| 845 | return rc; | ||
| 846 | } | ||
| 847 | info->has_iqueue = true; | ||
| 848 | } | ||
| 849 | |||
| 850 | return ring; | ||
| 851 | } | ||
| 852 | |||
| 853 | /* Initialize NotifGroup and buckets. | ||
| 854 | * This routine supports tile_net_init_mpipe(), below. | ||
| 855 | */ | ||
| 856 | static int init_notif_group_and_buckets(struct net_device *dev, | ||
| 857 | int ring, int network_cpus_count) | ||
| 858 | { | ||
| 859 | int group, rc; | ||
| 860 | |||
| 861 | /* Allocate one NotifGroup. */ | ||
| 862 | rc = gxio_mpipe_alloc_notif_groups(&context, 1, 0, 0); | ||
| 863 | if (rc < 0) { | ||
| 864 | netdev_err(dev, "gxio_mpipe_alloc_notif_groups failed: %d\n", | ||
| 865 | rc); | ||
| 866 | return rc; | ||
| 867 | } | ||
| 868 | group = rc; | ||
| 869 | |||
| 870 | /* Initialize global num_buckets value. */ | ||
| 871 | if (network_cpus_count > 4) | ||
| 872 | num_buckets = 256; | ||
| 873 | else if (network_cpus_count > 1) | ||
| 874 | num_buckets = 16; | ||
| 875 | |||
| 876 | /* Allocate some buckets, and set global first_bucket value. */ | ||
| 877 | rc = gxio_mpipe_alloc_buckets(&context, num_buckets, 0, 0); | ||
| 878 | if (rc < 0) { | ||
| 879 | netdev_err(dev, "gxio_mpipe_alloc_buckets failed: %d\n", rc); | ||
| 880 | return rc; | ||
| 881 | } | ||
| 882 | first_bucket = rc; | ||
| 883 | |||
| 884 | /* Init group and buckets. */ | ||
| 885 | rc = gxio_mpipe_init_notif_group_and_buckets( | ||
| 886 | &context, group, ring, network_cpus_count, | ||
| 887 | first_bucket, num_buckets, | ||
| 888 | GXIO_MPIPE_BUCKET_STICKY_FLOW_LOCALITY); | ||
| 889 | if (rc != 0) { | ||
| 890 | netdev_err( | ||
| 891 | dev, | ||
| 892 | "gxio_mpipe_init_notif_group_and_buckets failed: %d\n", | ||
| 893 | rc); | ||
| 894 | return rc; | ||
| 895 | } | ||
| 896 | |||
| 897 | return 0; | ||
| 898 | } | ||
| 899 | |||
| 900 | /* Create an irq and register it, then activate the irq and request | ||
| 901 | * interrupts on all cores. Note that "ingress_irq" being initialized | ||
| 902 | * is how we know not to call tile_net_init_mpipe() again. | ||
| 903 | * This routine supports tile_net_init_mpipe(), below. | ||
| 904 | */ | ||
| 905 | static int tile_net_setup_interrupts(struct net_device *dev) | ||
| 906 | { | ||
| 907 | int cpu, rc; | ||
| 908 | |||
| 909 | rc = create_irq(); | ||
| 910 | if (rc < 0) { | ||
| 911 | netdev_err(dev, "create_irq failed: %d\n", rc); | ||
| 912 | return rc; | ||
| 913 | } | ||
| 914 | ingress_irq = rc; | ||
| 915 | tile_irq_activate(ingress_irq, TILE_IRQ_PERCPU); | ||
| 916 | rc = request_irq(ingress_irq, tile_net_handle_ingress_irq, | ||
| 917 | 0, NULL, NULL); | ||
| 918 | if (rc != 0) { | ||
| 919 | netdev_err(dev, "request_irq failed: %d\n", rc); | ||
| 920 | destroy_irq(ingress_irq); | ||
| 921 | ingress_irq = -1; | ||
| 922 | return rc; | ||
| 923 | } | ||
| 924 | |||
| 925 | for_each_online_cpu(cpu) { | ||
| 926 | struct tile_net_info *info = &per_cpu(per_cpu_info, cpu); | ||
| 927 | if (info->has_iqueue) { | ||
| 928 | gxio_mpipe_request_notif_ring_interrupt( | ||
| 929 | &context, cpu_x(cpu), cpu_y(cpu), | ||
| 930 | 1, ingress_irq, info->iqueue.ring); | ||
| 931 | } | ||
| 932 | } | ||
| 933 | |||
| 934 | return 0; | ||
| 935 | } | ||
| 936 | |||
| 937 | /* Undo any state set up partially by a failed call to tile_net_init_mpipe. */ | ||
| 938 | static void tile_net_init_mpipe_fail(void) | ||
| 939 | { | ||
| 940 | int cpu; | ||
| 941 | |||
| 942 | /* Do cleanups that require the mpipe context first. */ | ||
| 943 | if (small_buffer_stack >= 0) | ||
| 944 | tile_net_pop_all_buffers(small_buffer_stack); | ||
| 945 | if (large_buffer_stack >= 0) | ||
| 946 | tile_net_pop_all_buffers(large_buffer_stack); | ||
| 947 | |||
| 948 | /* Destroy mpipe context so the hardware no longer owns any memory. */ | ||
| 949 | gxio_mpipe_destroy(&context); | ||
| 950 | |||
| 951 | for_each_online_cpu(cpu) { | ||
| 952 | struct tile_net_info *info = &per_cpu(per_cpu_info, cpu); | ||
| 953 | free_pages((unsigned long)(info->comps_for_echannel[0]), | ||
| 954 | get_order(COMPS_SIZE)); | ||
| 955 | info->comps_for_echannel[0] = NULL; | ||
| 956 | free_pages((unsigned long)(info->iqueue.idescs), | ||
| 957 | get_order(NOTIF_RING_SIZE)); | ||
| 958 | info->iqueue.idescs = NULL; | ||
| 959 | } | ||
| 960 | |||
| 961 | if (small_buffer_stack_va) | ||
| 962 | free_pages_exact(small_buffer_stack_va, buffer_stack_size); | ||
| 963 | if (large_buffer_stack_va) | ||
| 964 | free_pages_exact(large_buffer_stack_va, buffer_stack_size); | ||
| 965 | |||
| 966 | small_buffer_stack_va = NULL; | ||
| 967 | large_buffer_stack_va = NULL; | ||
| 968 | large_buffer_stack = -1; | ||
| 969 | small_buffer_stack = -1; | ||
| 970 | first_bucket = -1; | ||
| 971 | } | ||
| 972 | |||
| 973 | /* The first time any tilegx network device is opened, we initialize | ||
| 974 | * the global mpipe state. If this step fails, we fail to open the | ||
| 975 | * device, but if it succeeds, we never need to do it again, and since | ||
| 976 | * tile_net can't be unloaded, we never undo it. | ||
| 977 | * | ||
| 978 | * Note that some resources in this path (buffer stack indices, | ||
| 979 | * bindings from init_buffer_stack, etc.) are hypervisor resources | ||
| 980 | * that are freed implicitly by gxio_mpipe_destroy(). | ||
| 981 | */ | ||
| 982 | static int tile_net_init_mpipe(struct net_device *dev) | ||
| 983 | { | ||
| 984 | int i, num_buffers, rc; | ||
| 985 | int cpu; | ||
| 986 | int first_ring, ring; | ||
| 987 | int network_cpus_count = cpus_weight(network_cpus_map); | ||
| 988 | |||
| 989 | if (!hash_default) { | ||
| 990 | netdev_err(dev, "Networking requires hash_default!\n"); | ||
| 991 | return -EIO; | ||
| 992 | } | ||
| 993 | |||
| 994 | rc = gxio_mpipe_init(&context, 0); | ||
| 995 | if (rc != 0) { | ||
| 996 | netdev_err(dev, "gxio_mpipe_init failed: %d\n", rc); | ||
| 997 | return -EIO; | ||
| 998 | } | ||
| 999 | |||
| 1000 | /* Set up the buffer stacks. */ | ||
| 1001 | num_buffers = | ||
| 1002 | network_cpus_count * (IQUEUE_ENTRIES + TILE_NET_BATCH); | ||
| 1003 | rc = init_buffer_stacks(dev, num_buffers); | ||
| 1004 | if (rc != 0) | ||
| 1005 | goto fail; | ||
| 1006 | |||
| 1007 | /* Provide initial buffers. */ | ||
| 1008 | rc = -ENOMEM; | ||
| 1009 | for (i = 0; i < num_buffers; i++) { | ||
| 1010 | if (!tile_net_provide_buffer(true)) { | ||
| 1011 | netdev_err(dev, "Cannot allocate initial sk_bufs!\n"); | ||
| 1012 | goto fail; | ||
| 1013 | } | ||
| 1014 | } | ||
| 1015 | for (i = 0; i < num_buffers; i++) { | ||
| 1016 | if (!tile_net_provide_buffer(false)) { | ||
| 1017 | netdev_err(dev, "Cannot allocate initial sk_bufs!\n"); | ||
| 1018 | goto fail; | ||
| 1019 | } | ||
| 1020 | } | ||
| 1021 | |||
| 1022 | /* Allocate one NotifRing for each network cpu. */ | ||
| 1023 | rc = gxio_mpipe_alloc_notif_rings(&context, network_cpus_count, 0, 0); | ||
| 1024 | if (rc < 0) { | ||
| 1025 | netdev_err(dev, "gxio_mpipe_alloc_notif_rings failed %d\n", | ||
| 1026 | rc); | ||
| 1027 | goto fail; | ||
| 1028 | } | ||
| 1029 | |||
| 1030 | /* Init NotifRings per-cpu. */ | ||
| 1031 | first_ring = rc; | ||
| 1032 | ring = first_ring; | ||
| 1033 | for_each_online_cpu(cpu) { | ||
| 1034 | rc = alloc_percpu_mpipe_resources(dev, cpu, ring); | ||
| 1035 | if (rc < 0) | ||
| 1036 | goto fail; | ||
| 1037 | ring = rc; | ||
| 1038 | } | ||
| 1039 | |||
| 1040 | /* Initialize NotifGroup and buckets. */ | ||
| 1041 | rc = init_notif_group_and_buckets(dev, first_ring, network_cpus_count); | ||
| 1042 | if (rc != 0) | ||
| 1043 | goto fail; | ||
| 1044 | |||
| 1045 | /* Create and enable interrupts. */ | ||
| 1046 | rc = tile_net_setup_interrupts(dev); | ||
| 1047 | if (rc != 0) | ||
| 1048 | goto fail; | ||
| 1049 | |||
| 1050 | return 0; | ||
| 1051 | |||
| 1052 | fail: | ||
| 1053 | tile_net_init_mpipe_fail(); | ||
| 1054 | return rc; | ||
| 1055 | } | ||
| 1056 | |||
| 1057 | /* Create persistent egress info for a given egress channel. | ||
| 1058 | * Note that this may be shared between, say, "gbe0" and "xgbe0". | ||
| 1059 | * ISSUE: Defer header allocation until TSO is actually needed? | ||
| 1060 | */ | ||
| 1061 | static int tile_net_init_egress(struct net_device *dev, int echannel) | ||
| 1062 | { | ||
| 1063 | struct page *headers_page, *edescs_page, *equeue_page; | ||
| 1064 | gxio_mpipe_edesc_t *edescs; | ||
| 1065 | gxio_mpipe_equeue_t *equeue; | ||
| 1066 | unsigned char *headers; | ||
| 1067 | int headers_order, edescs_order, equeue_order; | ||
| 1068 | size_t edescs_size; | ||
| 1069 | int edma; | ||
| 1070 | int rc = -ENOMEM; | ||
| 1071 | |||
| 1072 | /* Only initialize once. */ | ||
| 1073 | if (egress_for_echannel[echannel].equeue != NULL) | ||
| 1074 | return 0; | ||
| 1075 | |||
| 1076 | /* Allocate memory for the "headers". */ | ||
| 1077 | headers_order = get_order(EQUEUE_ENTRIES * HEADER_BYTES); | ||
| 1078 | headers_page = alloc_pages(GFP_KERNEL, headers_order); | ||
| 1079 | if (headers_page == NULL) { | ||
| 1080 | netdev_warn(dev, | ||
| 1081 | "Could not alloc %zd bytes for TSO headers.\n", | ||
| 1082 | PAGE_SIZE << headers_order); | ||
| 1083 | goto fail; | ||
| 1084 | } | ||
| 1085 | headers = pfn_to_kaddr(page_to_pfn(headers_page)); | ||
| 1086 | |||
| 1087 | /* Allocate memory for the "edescs". */ | ||
| 1088 | edescs_size = EQUEUE_ENTRIES * sizeof(*edescs); | ||
| 1089 | edescs_order = get_order(edescs_size); | ||
| 1090 | edescs_page = alloc_pages(GFP_KERNEL, edescs_order); | ||
| 1091 | if (edescs_page == NULL) { | ||
| 1092 | netdev_warn(dev, | ||
| 1093 | "Could not alloc %zd bytes for eDMA ring.\n", | ||
| 1094 | edescs_size); | ||
| 1095 | goto fail_headers; | ||
| 1096 | } | ||
| 1097 | edescs = pfn_to_kaddr(page_to_pfn(edescs_page)); | ||
| 1098 | |||
| 1099 | /* Allocate memory for the "equeue". */ | ||
| 1100 | equeue_order = get_order(sizeof(*equeue)); | ||
| 1101 | equeue_page = alloc_pages(GFP_KERNEL, equeue_order); | ||
| 1102 | if (equeue_page == NULL) { | ||
| 1103 | netdev_warn(dev, | ||
| 1104 | "Could not alloc %zd bytes for equeue info.\n", | ||
| 1105 | PAGE_SIZE << equeue_order); | ||
| 1106 | goto fail_edescs; | ||
| 1107 | } | ||
| 1108 | equeue = pfn_to_kaddr(page_to_pfn(equeue_page)); | ||
| 1109 | |||
| 1110 | /* Allocate an edma ring. Note that in practice this can't | ||
| 1111 | * fail, which is good, because we will leak an edma ring if so. | ||
| 1112 | */ | ||
| 1113 | rc = gxio_mpipe_alloc_edma_rings(&context, 1, 0, 0); | ||
| 1114 | if (rc < 0) { | ||
| 1115 | netdev_warn(dev, "gxio_mpipe_alloc_edma_rings failed: %d\n", | ||
| 1116 | rc); | ||
| 1117 | goto fail_equeue; | ||
| 1118 | } | ||
| 1119 | edma = rc; | ||
| 1120 | |||
| 1121 | /* Initialize the equeue. */ | ||
| 1122 | rc = gxio_mpipe_equeue_init(equeue, &context, edma, echannel, | ||
| 1123 | edescs, edescs_size, 0); | ||
| 1124 | if (rc != 0) { | ||
| 1125 | netdev_err(dev, "gxio_mpipe_equeue_init failed: %d\n", rc); | ||
| 1126 | goto fail_equeue; | ||
| 1127 | } | ||
| 1128 | |||
| 1129 | /* Done. */ | ||
| 1130 | egress_for_echannel[echannel].equeue = equeue; | ||
| 1131 | egress_for_echannel[echannel].headers = headers; | ||
| 1132 | return 0; | ||
| 1133 | |||
| 1134 | fail_equeue: | ||
| 1135 | __free_pages(equeue_page, equeue_order); | ||
| 1136 | |||
| 1137 | fail_edescs: | ||
| 1138 | __free_pages(edescs_page, edescs_order); | ||
| 1139 | |||
| 1140 | fail_headers: | ||
| 1141 | __free_pages(headers_page, headers_order); | ||
| 1142 | |||
| 1143 | fail: | ||
| 1144 | return rc; | ||
| 1145 | } | ||
| 1146 | |||
| 1147 | /* Return channel number for a newly-opened link. */ | ||
| 1148 | static int tile_net_link_open(struct net_device *dev, gxio_mpipe_link_t *link, | ||
| 1149 | const char *link_name) | ||
| 1150 | { | ||
| 1151 | int rc = gxio_mpipe_link_open(link, &context, link_name, 0); | ||
| 1152 | if (rc < 0) { | ||
| 1153 | netdev_err(dev, "Failed to open '%s'\n", link_name); | ||
| 1154 | return rc; | ||
| 1155 | } | ||
| 1156 | rc = gxio_mpipe_link_channel(link); | ||
| 1157 | if (rc < 0 || rc >= TILE_NET_CHANNELS) { | ||
| 1158 | netdev_err(dev, "gxio_mpipe_link_channel bad value: %d\n", rc); | ||
| 1159 | gxio_mpipe_link_close(link); | ||
| 1160 | return -EINVAL; | ||
| 1161 | } | ||
| 1162 | return rc; | ||
| 1163 | } | ||
| 1164 | |||
| 1165 | /* Help the kernel activate the given network interface. */ | ||
| 1166 | static int tile_net_open(struct net_device *dev) | ||
| 1167 | { | ||
| 1168 | struct tile_net_priv *priv = netdev_priv(dev); | ||
| 1169 | int cpu, rc; | ||
| 1170 | |||
| 1171 | mutex_lock(&tile_net_devs_for_channel_mutex); | ||
| 1172 | |||
| 1173 | /* Do one-time initialization the first time any device is opened. */ | ||
| 1174 | if (ingress_irq < 0) { | ||
| 1175 | rc = tile_net_init_mpipe(dev); | ||
| 1176 | if (rc != 0) | ||
| 1177 | goto fail; | ||
| 1178 | } | ||
| 1179 | |||
| 1180 | /* Determine if this is the "loopify" device. */ | ||
| 1181 | if (unlikely((loopify_link_name != NULL) && | ||
| 1182 | !strcmp(dev->name, loopify_link_name))) { | ||
| 1183 | rc = tile_net_link_open(dev, &priv->link, "loop0"); | ||
| 1184 | if (rc < 0) | ||
| 1185 | goto fail; | ||
| 1186 | priv->channel = rc; | ||
| 1187 | rc = tile_net_link_open(dev, &priv->loopify_link, "loop1"); | ||
| 1188 | if (rc < 0) | ||
| 1189 | goto fail; | ||
| 1190 | priv->loopify_channel = rc; | ||
| 1191 | priv->echannel = rc; | ||
| 1192 | } else { | ||
| 1193 | rc = tile_net_link_open(dev, &priv->link, dev->name); | ||
| 1194 | if (rc < 0) | ||
| 1195 | goto fail; | ||
| 1196 | priv->channel = rc; | ||
| 1197 | priv->echannel = rc; | ||
| 1198 | } | ||
| 1199 | |||
| 1200 | /* Initialize egress info (if needed). Once ever, per echannel. */ | ||
| 1201 | rc = tile_net_init_egress(dev, priv->echannel); | ||
| 1202 | if (rc != 0) | ||
| 1203 | goto fail; | ||
| 1204 | |||
| 1205 | tile_net_devs_for_channel[priv->channel] = dev; | ||
| 1206 | |||
| 1207 | rc = tile_net_update(dev); | ||
| 1208 | if (rc != 0) | ||
| 1209 | goto fail; | ||
| 1210 | |||
| 1211 | mutex_unlock(&tile_net_devs_for_channel_mutex); | ||
| 1212 | |||
| 1213 | /* Initialize the transmit wake timer for this device for each cpu. */ | ||
| 1214 | for_each_online_cpu(cpu) { | ||
| 1215 | struct tile_net_info *info = &per_cpu(per_cpu_info, cpu); | ||
| 1216 | struct tile_net_tx_wake *tx_wake = | ||
| 1217 | &info->tx_wake[priv->echannel]; | ||
| 1218 | |||
| 1219 | hrtimer_init(&tx_wake->timer, CLOCK_MONOTONIC, | ||
| 1220 | HRTIMER_MODE_REL); | ||
| 1221 | tx_wake->timer.function = tile_net_handle_tx_wake_timer; | ||
| 1222 | tx_wake->dev = dev; | ||
| 1223 | } | ||
| 1224 | |||
| 1225 | for_each_online_cpu(cpu) | ||
| 1226 | netif_start_subqueue(dev, cpu); | ||
| 1227 | netif_carrier_on(dev); | ||
| 1228 | return 0; | ||
| 1229 | |||
| 1230 | fail: | ||
| 1231 | if (priv->loopify_channel >= 0) { | ||
| 1232 | if (gxio_mpipe_link_close(&priv->loopify_link) != 0) | ||
| 1233 | netdev_warn(dev, "Failed to close loopify link!\n"); | ||
| 1234 | priv->loopify_channel = -1; | ||
| 1235 | } | ||
| 1236 | if (priv->channel >= 0) { | ||
| 1237 | if (gxio_mpipe_link_close(&priv->link) != 0) | ||
| 1238 | netdev_warn(dev, "Failed to close link!\n"); | ||
| 1239 | priv->channel = -1; | ||
| 1240 | } | ||
| 1241 | priv->echannel = -1; | ||
| 1242 | tile_net_devs_for_channel[priv->channel] = NULL; | ||
| 1243 | mutex_unlock(&tile_net_devs_for_channel_mutex); | ||
| 1244 | |||
| 1245 | /* Don't return raw gxio error codes to generic Linux. */ | ||
| 1246 | return (rc > -512) ? rc : -EIO; | ||
| 1247 | } | ||
| 1248 | |||
| 1249 | /* Help the kernel deactivate the given network interface. */ | ||
| 1250 | static int tile_net_stop(struct net_device *dev) | ||
| 1251 | { | ||
| 1252 | struct tile_net_priv *priv = netdev_priv(dev); | ||
| 1253 | int cpu; | ||
| 1254 | |||
| 1255 | for_each_online_cpu(cpu) { | ||
| 1256 | struct tile_net_info *info = &per_cpu(per_cpu_info, cpu); | ||
| 1257 | struct tile_net_tx_wake *tx_wake = | ||
| 1258 | &info->tx_wake[priv->echannel]; | ||
| 1259 | |||
| 1260 | hrtimer_cancel(&tx_wake->timer); | ||
| 1261 | netif_stop_subqueue(dev, cpu); | ||
| 1262 | } | ||
| 1263 | |||
| 1264 | mutex_lock(&tile_net_devs_for_channel_mutex); | ||
| 1265 | tile_net_devs_for_channel[priv->channel] = NULL; | ||
| 1266 | (void)tile_net_update(dev); | ||
| 1267 | if (priv->loopify_channel >= 0) { | ||
| 1268 | if (gxio_mpipe_link_close(&priv->loopify_link) != 0) | ||
| 1269 | netdev_warn(dev, "Failed to close loopify link!\n"); | ||
| 1270 | priv->loopify_channel = -1; | ||
| 1271 | } | ||
| 1272 | if (priv->channel >= 0) { | ||
| 1273 | if (gxio_mpipe_link_close(&priv->link) != 0) | ||
| 1274 | netdev_warn(dev, "Failed to close link!\n"); | ||
| 1275 | priv->channel = -1; | ||
| 1276 | } | ||
| 1277 | priv->echannel = -1; | ||
| 1278 | mutex_unlock(&tile_net_devs_for_channel_mutex); | ||
| 1279 | |||
| 1280 | return 0; | ||
| 1281 | } | ||
| 1282 | |||
| 1283 | /* Determine the VA for a fragment. */ | ||
| 1284 | static inline void *tile_net_frag_buf(skb_frag_t *f) | ||
| 1285 | { | ||
| 1286 | unsigned long pfn = page_to_pfn(skb_frag_page(f)); | ||
| 1287 | return pfn_to_kaddr(pfn) + f->page_offset; | ||
| 1288 | } | ||
| 1289 | |||
| 1290 | /* Acquire a completion entry and an egress slot, or if we can't, | ||
| 1291 | * stop the queue and schedule the tx_wake timer. | ||
| 1292 | */ | ||
| 1293 | static s64 tile_net_equeue_try_reserve(struct net_device *dev, | ||
| 1294 | struct tile_net_comps *comps, | ||
| 1295 | gxio_mpipe_equeue_t *equeue, | ||
| 1296 | int num_edescs) | ||
| 1297 | { | ||
| 1298 | /* Try to acquire a completion entry. */ | ||
| 1299 | if (comps->comp_next - comps->comp_last < TILE_NET_MAX_COMPS - 1 || | ||
| 1300 | tile_net_free_comps(equeue, comps, 32, false) != 0) { | ||
| 1301 | |||
| 1302 | /* Try to acquire an egress slot. */ | ||
| 1303 | s64 slot = gxio_mpipe_equeue_try_reserve(equeue, num_edescs); | ||
| 1304 | if (slot >= 0) | ||
| 1305 | return slot; | ||
| 1306 | |||
| 1307 | /* Freeing some completions gives the equeue time to drain. */ | ||
| 1308 | tile_net_free_comps(equeue, comps, TILE_NET_MAX_COMPS, false); | ||
| 1309 | |||
| 1310 | slot = gxio_mpipe_equeue_try_reserve(equeue, num_edescs); | ||
| 1311 | if (slot >= 0) | ||
| 1312 | return slot; | ||
| 1313 | } | ||
| 1314 | |||
| 1315 | /* Still nothing; give up and stop the queue for a short while. */ | ||
| 1316 | netif_stop_subqueue(dev, smp_processor_id()); | ||
| 1317 | tile_net_schedule_tx_wake_timer(dev); | ||
| 1318 | return -1; | ||
| 1319 | } | ||
| 1320 | |||
| 1321 | /* Determine how many edesc's are needed for TSO. | ||
| 1322 | * | ||
| 1323 | * Sometimes, if "sendfile()" requires copying, we will be called with | ||
| 1324 | * "data" containing the header and payload, with "frags" being empty. | ||
| 1325 | * Sometimes, for example when using NFS over TCP, a single segment can | ||
| 1326 | * span 3 fragments. This requires special care. | ||
| 1327 | */ | ||
| 1328 | static int tso_count_edescs(struct sk_buff *skb) | ||
| 1329 | { | ||
| 1330 | struct skb_shared_info *sh = skb_shinfo(skb); | ||
| 1331 | unsigned int data_len = skb->data_len; | ||
| 1332 | unsigned int p_len = sh->gso_size; | ||
| 1333 | long f_id = -1; /* id of the current fragment */ | ||
| 1334 | long f_size = -1; /* size of the current fragment */ | ||
| 1335 | long f_used = -1; /* bytes used from the current fragment */ | ||
| 1336 | long n; /* size of the current piece of payload */ | ||
| 1337 | int num_edescs = 0; | ||
| 1338 | int segment; | ||
| 1339 | |||
| 1340 | for (segment = 0; segment < sh->gso_segs; segment++) { | ||
| 1341 | |||
| 1342 | unsigned int p_used = 0; | ||
| 1343 | |||
| 1344 | /* One edesc for header and for each piece of the payload. */ | ||
| 1345 | for (num_edescs++; p_used < p_len; num_edescs++) { | ||
| 1346 | |||
| 1347 | /* Advance as needed. */ | ||
| 1348 | while (f_used >= f_size) { | ||
| 1349 | f_id++; | ||
| 1350 | f_size = sh->frags[f_id].size; | ||
| 1351 | f_used = 0; | ||
| 1352 | } | ||
| 1353 | |||
| 1354 | /* Use bytes from the current fragment. */ | ||
| 1355 | n = p_len - p_used; | ||
| 1356 | if (n > f_size - f_used) | ||
| 1357 | n = f_size - f_used; | ||
| 1358 | f_used += n; | ||
| 1359 | p_used += n; | ||
| 1360 | } | ||
| 1361 | |||
| 1362 | /* The last segment may be less than gso_size. */ | ||
| 1363 | data_len -= p_len; | ||
| 1364 | if (data_len < p_len) | ||
| 1365 | p_len = data_len; | ||
| 1366 | } | ||
| 1367 | |||
| 1368 | return num_edescs; | ||
| 1369 | } | ||
| 1370 | |||
| 1371 | /* Prepare modified copies of the skbuff headers. | ||
| 1372 | * FIXME: add support for IPv6. | ||
| 1373 | */ | ||
| 1374 | static void tso_headers_prepare(struct sk_buff *skb, unsigned char *headers, | ||
| 1375 | s64 slot) | ||
| 1376 | { | ||
| 1377 | struct skb_shared_info *sh = skb_shinfo(skb); | ||
| 1378 | struct iphdr *ih; | ||
| 1379 | struct tcphdr *th; | ||
| 1380 | unsigned int data_len = skb->data_len; | ||
| 1381 | unsigned char *data = skb->data; | ||
| 1382 | unsigned int ih_off, th_off, sh_len, p_len; | ||
| 1383 | unsigned int isum_seed, tsum_seed, id, seq; | ||
| 1384 | long f_id = -1; /* id of the current fragment */ | ||
| 1385 | long f_size = -1; /* size of the current fragment */ | ||
| 1386 | long f_used = -1; /* bytes used from the current fragment */ | ||
| 1387 | long n; /* size of the current piece of payload */ | ||
| 1388 | int segment; | ||
| 1389 | |||
| 1390 | /* Locate original headers and compute various lengths. */ | ||
| 1391 | ih = ip_hdr(skb); | ||
| 1392 | th = tcp_hdr(skb); | ||
| 1393 | ih_off = skb_network_offset(skb); | ||
| 1394 | th_off = skb_transport_offset(skb); | ||
| 1395 | sh_len = th_off + tcp_hdrlen(skb); | ||
| 1396 | p_len = sh->gso_size; | ||
| 1397 | |||
| 1398 | /* Set up seed values for IP and TCP csum and initialize id and seq. */ | ||
| 1399 | isum_seed = ((0xFFFF - ih->check) + | ||
| 1400 | (0xFFFF - ih->tot_len) + | ||
| 1401 | (0xFFFF - ih->id)); | ||
| 1402 | tsum_seed = th->check + (0xFFFF ^ htons(skb->len)); | ||
| 1403 | id = ntohs(ih->id); | ||
| 1404 | seq = ntohl(th->seq); | ||
| 1405 | |||
| 1406 | /* Prepare all the headers. */ | ||
| 1407 | for (segment = 0; segment < sh->gso_segs; segment++) { | ||
| 1408 | unsigned char *buf; | ||
| 1409 | unsigned int p_used = 0; | ||
| 1410 | |||
| 1411 | /* Copy to the header memory for this segment. */ | ||
| 1412 | buf = headers + (slot % EQUEUE_ENTRIES) * HEADER_BYTES + | ||
| 1413 | NET_IP_ALIGN; | ||
| 1414 | memcpy(buf, data, sh_len); | ||
| 1415 | |||
| 1416 | /* Update copied ip header. */ | ||
| 1417 | ih = (struct iphdr *)(buf + ih_off); | ||
| 1418 | ih->tot_len = htons(sh_len + p_len - ih_off); | ||
| 1419 | ih->id = htons(id); | ||
| 1420 | ih->check = csum_long(isum_seed + ih->tot_len + | ||
| 1421 | ih->id) ^ 0xffff; | ||
| 1422 | |||
| 1423 | /* Update copied tcp header. */ | ||
| 1424 | th = (struct tcphdr *)(buf + th_off); | ||
| 1425 | th->seq = htonl(seq); | ||
| 1426 | th->check = csum_long(tsum_seed + htons(sh_len + p_len)); | ||
| 1427 | if (segment != sh->gso_segs - 1) { | ||
| 1428 | th->fin = 0; | ||
| 1429 | th->psh = 0; | ||
| 1430 | } | ||
| 1431 | |||
| 1432 | /* Skip past the header. */ | ||
| 1433 | slot++; | ||
| 1434 | |||
| 1435 | /* Skip past the payload. */ | ||
| 1436 | while (p_used < p_len) { | ||
| 1437 | |||
| 1438 | /* Advance as needed. */ | ||
| 1439 | while (f_used >= f_size) { | ||
| 1440 | f_id++; | ||
| 1441 | f_size = sh->frags[f_id].size; | ||
| 1442 | f_used = 0; | ||
| 1443 | } | ||
| 1444 | |||
| 1445 | /* Use bytes from the current fragment. */ | ||
| 1446 | n = p_len - p_used; | ||
| 1447 | if (n > f_size - f_used) | ||
| 1448 | n = f_size - f_used; | ||
| 1449 | f_used += n; | ||
| 1450 | p_used += n; | ||
| 1451 | |||
| 1452 | slot++; | ||
| 1453 | } | ||
| 1454 | |||
| 1455 | id++; | ||
| 1456 | seq += p_len; | ||
| 1457 | |||
| 1458 | /* The last segment may be less than gso_size. */ | ||
| 1459 | data_len -= p_len; | ||
| 1460 | if (data_len < p_len) | ||
| 1461 | p_len = data_len; | ||
| 1462 | } | ||
| 1463 | |||
| 1464 | /* Flush the headers so they are ready for hardware DMA. */ | ||
| 1465 | wmb(); | ||
| 1466 | } | ||
| 1467 | |||
| 1468 | /* Pass all the data to mpipe for egress. */ | ||
| 1469 | static void tso_egress(struct net_device *dev, gxio_mpipe_equeue_t *equeue, | ||
| 1470 | struct sk_buff *skb, unsigned char *headers, s64 slot) | ||
| 1471 | { | ||
| 1472 | struct tile_net_priv *priv = netdev_priv(dev); | ||
| 1473 | struct skb_shared_info *sh = skb_shinfo(skb); | ||
| 1474 | unsigned int data_len = skb->data_len; | ||
| 1475 | unsigned int p_len = sh->gso_size; | ||
| 1476 | gxio_mpipe_edesc_t edesc_head = { { 0 } }; | ||
| 1477 | gxio_mpipe_edesc_t edesc_body = { { 0 } }; | ||
| 1478 | long f_id = -1; /* id of the current fragment */ | ||
| 1479 | long f_size = -1; /* size of the current fragment */ | ||
| 1480 | long f_used = -1; /* bytes used from the current fragment */ | ||
| 1481 | long n; /* size of the current piece of payload */ | ||
| 1482 | unsigned long tx_packets = 0, tx_bytes = 0; | ||
| 1483 | unsigned int csum_start, sh_len; | ||
| 1484 | int segment; | ||
| 1485 | |||
| 1486 | /* Prepare to egress the headers: set up header edesc. */ | ||
| 1487 | csum_start = skb_checksum_start_offset(skb); | ||
| 1488 | sh_len = skb_transport_offset(skb) + tcp_hdrlen(skb); | ||
| 1489 | edesc_head.csum = 1; | ||
| 1490 | edesc_head.csum_start = csum_start; | ||
| 1491 | edesc_head.csum_dest = csum_start + skb->csum_offset; | ||
| 1492 | edesc_head.xfer_size = sh_len; | ||
| 1493 | |||
| 1494 | /* This is only used to specify the TLB. */ | ||
| 1495 | edesc_head.stack_idx = large_buffer_stack; | ||
| 1496 | edesc_body.stack_idx = large_buffer_stack; | ||
| 1497 | |||
| 1498 | /* Egress all the edescs. */ | ||
| 1499 | for (segment = 0; segment < sh->gso_segs; segment++) { | ||
| 1500 | void *va; | ||
| 1501 | unsigned char *buf; | ||
| 1502 | unsigned int p_used = 0; | ||
| 1503 | |||
| 1504 | /* Egress the header. */ | ||
| 1505 | buf = headers + (slot % EQUEUE_ENTRIES) * HEADER_BYTES + | ||
| 1506 | NET_IP_ALIGN; | ||
| 1507 | edesc_head.va = va_to_tile_io_addr(buf); | ||
| 1508 | gxio_mpipe_equeue_put_at(equeue, edesc_head, slot); | ||
| 1509 | slot++; | ||
| 1510 | |||
| 1511 | /* Egress the payload. */ | ||
| 1512 | while (p_used < p_len) { | ||
| 1513 | |||
| 1514 | /* Advance as needed. */ | ||
| 1515 | while (f_used >= f_size) { | ||
| 1516 | f_id++; | ||
| 1517 | f_size = sh->frags[f_id].size; | ||
| 1518 | f_used = 0; | ||
| 1519 | } | ||
| 1520 | |||
| 1521 | va = tile_net_frag_buf(&sh->frags[f_id]) + f_used; | ||
| 1522 | |||
| 1523 | /* Use bytes from the current fragment. */ | ||
| 1524 | n = p_len - p_used; | ||
| 1525 | if (n > f_size - f_used) | ||
| 1526 | n = f_size - f_used; | ||
| 1527 | f_used += n; | ||
| 1528 | p_used += n; | ||
| 1529 | |||
| 1530 | /* Egress a piece of the payload. */ | ||
| 1531 | edesc_body.va = va_to_tile_io_addr(va); | ||
| 1532 | edesc_body.xfer_size = n; | ||
| 1533 | edesc_body.bound = !(p_used < p_len); | ||
| 1534 | gxio_mpipe_equeue_put_at(equeue, edesc_body, slot); | ||
| 1535 | slot++; | ||
| 1536 | } | ||
| 1537 | |||
| 1538 | tx_packets++; | ||
| 1539 | tx_bytes += sh_len + p_len; | ||
| 1540 | |||
| 1541 | /* The last segment may be less than gso_size. */ | ||
| 1542 | data_len -= p_len; | ||
| 1543 | if (data_len < p_len) | ||
| 1544 | p_len = data_len; | ||
| 1545 | } | ||
| 1546 | |||
| 1547 | /* Update stats. */ | ||
| 1548 | tile_net_stats_add(tx_packets, &priv->stats.tx_packets); | ||
| 1549 | tile_net_stats_add(tx_bytes, &priv->stats.tx_bytes); | ||
| 1550 | } | ||
| 1551 | |||
| 1552 | /* Do "TSO" handling for egress. | ||
| 1553 | * | ||
| 1554 | * Normally drivers set NETIF_F_TSO only to support hardware TSO; | ||
| 1555 | * otherwise the stack uses scatter-gather to implement GSO in software. | ||
| 1556 | * On our testing, enabling GSO support (via NETIF_F_SG) drops network | ||
| 1557 | * performance down to around 7.5 Gbps on the 10G interfaces, although | ||
| 1558 | * also dropping cpu utilization way down, to under 8%. But | ||
| 1559 | * implementing "TSO" in the driver brings performance back up to line | ||
| 1560 | * rate, while dropping cpu usage even further, to less than 4%. In | ||
| 1561 | * practice, profiling of GSO shows that skb_segment() is what causes | ||
| 1562 | * the performance overheads; we benefit in the driver from using | ||
| 1563 | * preallocated memory to duplicate the TCP/IP headers. | ||
| 1564 | */ | ||
| 1565 | static int tile_net_tx_tso(struct sk_buff *skb, struct net_device *dev) | ||
| 1566 | { | ||
| 1567 | struct tile_net_info *info = &__get_cpu_var(per_cpu_info); | ||
| 1568 | struct tile_net_priv *priv = netdev_priv(dev); | ||
| 1569 | int channel = priv->echannel; | ||
| 1570 | struct tile_net_egress *egress = &egress_for_echannel[channel]; | ||
| 1571 | struct tile_net_comps *comps = info->comps_for_echannel[channel]; | ||
| 1572 | gxio_mpipe_equeue_t *equeue = egress->equeue; | ||
| 1573 | unsigned long irqflags; | ||
| 1574 | int num_edescs; | ||
| 1575 | s64 slot; | ||
| 1576 | |||
| 1577 | /* Determine how many mpipe edesc's are needed. */ | ||
| 1578 | num_edescs = tso_count_edescs(skb); | ||
| 1579 | |||
| 1580 | local_irq_save(irqflags); | ||
| 1581 | |||
| 1582 | /* Try to acquire a completion entry and an egress slot. */ | ||
| 1583 | slot = tile_net_equeue_try_reserve(dev, comps, equeue, num_edescs); | ||
| 1584 | if (slot < 0) { | ||
| 1585 | local_irq_restore(irqflags); | ||
| 1586 | return NETDEV_TX_BUSY; | ||
| 1587 | } | ||
| 1588 | |||
| 1589 | /* Set up copies of header data properly. */ | ||
| 1590 | tso_headers_prepare(skb, egress->headers, slot); | ||
| 1591 | |||
| 1592 | /* Actually pass the data to the network hardware. */ | ||
| 1593 | tso_egress(dev, equeue, skb, egress->headers, slot); | ||
| 1594 | |||
| 1595 | /* Add a completion record. */ | ||
| 1596 | add_comp(equeue, comps, slot + num_edescs - 1, skb); | ||
| 1597 | |||
| 1598 | local_irq_restore(irqflags); | ||
| 1599 | |||
| 1600 | /* Make sure the egress timer is scheduled. */ | ||
| 1601 | tile_net_schedule_egress_timer(); | ||
| 1602 | |||
| 1603 | return NETDEV_TX_OK; | ||
| 1604 | } | ||
| 1605 | |||
| 1606 | /* Analyze the body and frags for a transmit request. */ | ||
| 1607 | static unsigned int tile_net_tx_frags(struct frag *frags, | ||
| 1608 | struct sk_buff *skb, | ||
| 1609 | void *b_data, unsigned int b_len) | ||
| 1610 | { | ||
| 1611 | unsigned int i, n = 0; | ||
| 1612 | |||
| 1613 | struct skb_shared_info *sh = skb_shinfo(skb); | ||
| 1614 | |||
| 1615 | if (b_len != 0) { | ||
| 1616 | frags[n].buf = b_data; | ||
| 1617 | frags[n++].length = b_len; | ||
| 1618 | } | ||
| 1619 | |||
| 1620 | for (i = 0; i < sh->nr_frags; i++) { | ||
| 1621 | skb_frag_t *f = &sh->frags[i]; | ||
| 1622 | frags[n].buf = tile_net_frag_buf(f); | ||
| 1623 | frags[n++].length = skb_frag_size(f); | ||
| 1624 | } | ||
| 1625 | |||
| 1626 | return n; | ||
| 1627 | } | ||
| 1628 | |||
| 1629 | /* Help the kernel transmit a packet. */ | ||
| 1630 | static int tile_net_tx(struct sk_buff *skb, struct net_device *dev) | ||
| 1631 | { | ||
| 1632 | struct tile_net_info *info = &__get_cpu_var(per_cpu_info); | ||
| 1633 | struct tile_net_priv *priv = netdev_priv(dev); | ||
| 1634 | struct tile_net_egress *egress = &egress_for_echannel[priv->echannel]; | ||
| 1635 | gxio_mpipe_equeue_t *equeue = egress->equeue; | ||
| 1636 | struct tile_net_comps *comps = | ||
| 1637 | info->comps_for_echannel[priv->echannel]; | ||
| 1638 | unsigned int len = skb->len; | ||
| 1639 | unsigned char *data = skb->data; | ||
| 1640 | unsigned int num_edescs; | ||
| 1641 | struct frag frags[MAX_FRAGS]; | ||
| 1642 | gxio_mpipe_edesc_t edescs[MAX_FRAGS]; | ||
| 1643 | unsigned long irqflags; | ||
| 1644 | gxio_mpipe_edesc_t edesc = { { 0 } }; | ||
| 1645 | unsigned int i; | ||
| 1646 | s64 slot; | ||
| 1647 | |||
| 1648 | if (skb_is_gso(skb)) | ||
| 1649 | return tile_net_tx_tso(skb, dev); | ||
| 1650 | |||
| 1651 | num_edescs = tile_net_tx_frags(frags, skb, data, skb_headlen(skb)); | ||
| 1652 | |||
| 1653 | /* This is only used to specify the TLB. */ | ||
| 1654 | edesc.stack_idx = large_buffer_stack; | ||
| 1655 | |||
| 1656 | /* Prepare the edescs. */ | ||
| 1657 | for (i = 0; i < num_edescs; i++) { | ||
| 1658 | edesc.xfer_size = frags[i].length; | ||
| 1659 | edesc.va = va_to_tile_io_addr(frags[i].buf); | ||
| 1660 | edescs[i] = edesc; | ||
| 1661 | } | ||
| 1662 | |||
| 1663 | /* Mark the final edesc. */ | ||
| 1664 | edescs[num_edescs - 1].bound = 1; | ||
| 1665 | |||
| 1666 | /* Add checksum info to the initial edesc, if needed. */ | ||
| 1667 | if (skb->ip_summed == CHECKSUM_PARTIAL) { | ||
| 1668 | unsigned int csum_start = skb_checksum_start_offset(skb); | ||
| 1669 | edescs[0].csum = 1; | ||
| 1670 | edescs[0].csum_start = csum_start; | ||
| 1671 | edescs[0].csum_dest = csum_start + skb->csum_offset; | ||
| 1672 | } | ||
| 1673 | |||
| 1674 | local_irq_save(irqflags); | ||
| 1675 | |||
| 1676 | /* Try to acquire a completion entry and an egress slot. */ | ||
| 1677 | slot = tile_net_equeue_try_reserve(dev, comps, equeue, num_edescs); | ||
| 1678 | if (slot < 0) { | ||
| 1679 | local_irq_restore(irqflags); | ||
| 1680 | return NETDEV_TX_BUSY; | ||
| 1681 | } | ||
| 1682 | |||
| 1683 | for (i = 0; i < num_edescs; i++) | ||
| 1684 | gxio_mpipe_equeue_put_at(equeue, edescs[i], slot++); | ||
| 1685 | |||
| 1686 | /* Add a completion record. */ | ||
| 1687 | add_comp(equeue, comps, slot - 1, skb); | ||
| 1688 | |||
| 1689 | /* NOTE: Use ETH_ZLEN for short packets (e.g. 42 < 60). */ | ||
| 1690 | tile_net_stats_add(1, &priv->stats.tx_packets); | ||
| 1691 | tile_net_stats_add(max_t(unsigned int, len, ETH_ZLEN), | ||
| 1692 | &priv->stats.tx_bytes); | ||
| 1693 | |||
| 1694 | local_irq_restore(irqflags); | ||
| 1695 | |||
| 1696 | /* Make sure the egress timer is scheduled. */ | ||
| 1697 | tile_net_schedule_egress_timer(); | ||
| 1698 | |||
| 1699 | return NETDEV_TX_OK; | ||
| 1700 | } | ||
| 1701 | |||
| 1702 | /* Return subqueue id on this core (one per core). */ | ||
| 1703 | static u16 tile_net_select_queue(struct net_device *dev, struct sk_buff *skb) | ||
| 1704 | { | ||
| 1705 | return smp_processor_id(); | ||
| 1706 | } | ||
| 1707 | |||
| 1708 | /* Deal with a transmit timeout. */ | ||
| 1709 | static void tile_net_tx_timeout(struct net_device *dev) | ||
| 1710 | { | ||
| 1711 | int cpu; | ||
| 1712 | |||
| 1713 | for_each_online_cpu(cpu) | ||
| 1714 | netif_wake_subqueue(dev, cpu); | ||
| 1715 | } | ||
| 1716 | |||
| 1717 | /* Ioctl commands. */ | ||
| 1718 | static int tile_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | ||
| 1719 | { | ||
| 1720 | return -EOPNOTSUPP; | ||
| 1721 | } | ||
| 1722 | |||
| 1723 | /* Get system network statistics for device. */ | ||
| 1724 | static struct net_device_stats *tile_net_get_stats(struct net_device *dev) | ||
| 1725 | { | ||
| 1726 | struct tile_net_priv *priv = netdev_priv(dev); | ||
| 1727 | return &priv->stats; | ||
| 1728 | } | ||
| 1729 | |||
| 1730 | /* Change the MTU. */ | ||
| 1731 | static int tile_net_change_mtu(struct net_device *dev, int new_mtu) | ||
| 1732 | { | ||
| 1733 | if ((new_mtu < 68) || (new_mtu > 1500)) | ||
| 1734 | return -EINVAL; | ||
| 1735 | dev->mtu = new_mtu; | ||
| 1736 | return 0; | ||
| 1737 | } | ||
| 1738 | |||
| 1739 | /* Change the Ethernet address of the NIC. | ||
| 1740 | * | ||
| 1741 | * The hypervisor driver does not support changing MAC address. However, | ||
| 1742 | * the hardware does not do anything with the MAC address, so the address | ||
| 1743 | * which gets used on outgoing packets, and which is accepted on incoming | ||
| 1744 | * packets, is completely up to us. | ||
| 1745 | * | ||
| 1746 | * Returns 0 on success, negative on failure. | ||
| 1747 | */ | ||
| 1748 | static int tile_net_set_mac_address(struct net_device *dev, void *p) | ||
| 1749 | { | ||
| 1750 | struct sockaddr *addr = p; | ||
| 1751 | |||
| 1752 | if (!is_valid_ether_addr(addr->sa_data)) | ||
| 1753 | return -EINVAL; | ||
| 1754 | memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); | ||
| 1755 | return 0; | ||
| 1756 | } | ||
| 1757 | |||
| 1758 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
| 1759 | /* Polling 'interrupt' - used by things like netconsole to send skbs | ||
| 1760 | * without having to re-enable interrupts. It's not called while | ||
| 1761 | * the interrupt routine is executing. | ||
| 1762 | */ | ||
| 1763 | static void tile_net_netpoll(struct net_device *dev) | ||
| 1764 | { | ||
| 1765 | disable_percpu_irq(ingress_irq); | ||
| 1766 | tile_net_handle_ingress_irq(ingress_irq, NULL); | ||
| 1767 | enable_percpu_irq(ingress_irq, 0); | ||
| 1768 | } | ||
| 1769 | #endif | ||
| 1770 | |||
| 1771 | static const struct net_device_ops tile_net_ops = { | ||
| 1772 | .ndo_open = tile_net_open, | ||
| 1773 | .ndo_stop = tile_net_stop, | ||
| 1774 | .ndo_start_xmit = tile_net_tx, | ||
| 1775 | .ndo_select_queue = tile_net_select_queue, | ||
| 1776 | .ndo_do_ioctl = tile_net_ioctl, | ||
| 1777 | .ndo_get_stats = tile_net_get_stats, | ||
| 1778 | .ndo_change_mtu = tile_net_change_mtu, | ||
| 1779 | .ndo_tx_timeout = tile_net_tx_timeout, | ||
| 1780 | .ndo_set_mac_address = tile_net_set_mac_address, | ||
| 1781 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
| 1782 | .ndo_poll_controller = tile_net_netpoll, | ||
| 1783 | #endif | ||
| 1784 | }; | ||
| 1785 | |||
| 1786 | /* The setup function. | ||
| 1787 | * | ||
| 1788 | * This uses ether_setup() to assign various fields in dev, including | ||
| 1789 | * setting IFF_BROADCAST and IFF_MULTICAST, then sets some extra fields. | ||
| 1790 | */ | ||
| 1791 | static void tile_net_setup(struct net_device *dev) | ||
| 1792 | { | ||
| 1793 | ether_setup(dev); | ||
| 1794 | dev->netdev_ops = &tile_net_ops; | ||
| 1795 | dev->watchdog_timeo = TILE_NET_TIMEOUT; | ||
| 1796 | dev->features |= NETIF_F_LLTX; | ||
| 1797 | dev->features |= NETIF_F_HW_CSUM; | ||
| 1798 | dev->features |= NETIF_F_SG; | ||
| 1799 | dev->features |= NETIF_F_TSO; | ||
| 1800 | dev->mtu = 1500; | ||
| 1801 | } | ||
| 1802 | |||
| 1803 | /* Allocate the device structure, register the device, and obtain the | ||
| 1804 | * MAC address from the hypervisor. | ||
| 1805 | */ | ||
| 1806 | static void tile_net_dev_init(const char *name, const uint8_t *mac) | ||
| 1807 | { | ||
| 1808 | int ret; | ||
| 1809 | int i; | ||
| 1810 | int nz_addr = 0; | ||
| 1811 | struct net_device *dev; | ||
| 1812 | struct tile_net_priv *priv; | ||
| 1813 | |||
| 1814 | /* HACK: Ignore "loop" links. */ | ||
| 1815 | if (strncmp(name, "loop", 4) == 0) | ||
| 1816 | return; | ||
| 1817 | |||
| 1818 | /* Allocate the device structure. Normally, "name" is a | ||
| 1819 | * template, instantiated by register_netdev(), but not for us. | ||
| 1820 | */ | ||
| 1821 | dev = alloc_netdev_mqs(sizeof(*priv), name, tile_net_setup, | ||
| 1822 | NR_CPUS, 1); | ||
| 1823 | if (!dev) { | ||
| 1824 | pr_err("alloc_netdev_mqs(%s) failed\n", name); | ||
| 1825 | return; | ||
| 1826 | } | ||
| 1827 | |||
| 1828 | /* Initialize "priv". */ | ||
| 1829 | priv = netdev_priv(dev); | ||
| 1830 | memset(priv, 0, sizeof(*priv)); | ||
| 1831 | priv->dev = dev; | ||
| 1832 | priv->channel = -1; | ||
| 1833 | priv->loopify_channel = -1; | ||
| 1834 | priv->echannel = -1; | ||
| 1835 | |||
| 1836 | /* Get the MAC address and set it in the device struct; this must | ||
| 1837 | * be done before the device is opened. If the MAC is all zeroes, | ||
| 1838 | * we use a random address, since we're probably on the simulator. | ||
| 1839 | */ | ||
| 1840 | for (i = 0; i < 6; i++) | ||
| 1841 | nz_addr |= mac[i]; | ||
| 1842 | |||
| 1843 | if (nz_addr) { | ||
| 1844 | memcpy(dev->dev_addr, mac, 6); | ||
| 1845 | dev->addr_len = 6; | ||
| 1846 | } else { | ||
| 1847 | random_ether_addr(dev->dev_addr); | ||
| 1848 | } | ||
| 1849 | |||
| 1850 | /* Register the network device. */ | ||
| 1851 | ret = register_netdev(dev); | ||
| 1852 | if (ret) { | ||
| 1853 | netdev_err(dev, "register_netdev failed %d\n", ret); | ||
| 1854 | free_netdev(dev); | ||
| 1855 | return; | ||
| 1856 | } | ||
| 1857 | } | ||
| 1858 | |||
| 1859 | /* Per-cpu module initialization. */ | ||
| 1860 | static void tile_net_init_module_percpu(void *unused) | ||
| 1861 | { | ||
| 1862 | struct tile_net_info *info = &__get_cpu_var(per_cpu_info); | ||
| 1863 | int my_cpu = smp_processor_id(); | ||
| 1864 | |||
| 1865 | info->has_iqueue = false; | ||
| 1866 | |||
| 1867 | info->my_cpu = my_cpu; | ||
| 1868 | |||
| 1869 | /* Initialize the egress timer. */ | ||
| 1870 | hrtimer_init(&info->egress_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); | ||
| 1871 | info->egress_timer.function = tile_net_handle_egress_timer; | ||
| 1872 | } | ||
| 1873 | |||
| 1874 | /* Module initialization. */ | ||
| 1875 | static int __init tile_net_init_module(void) | ||
| 1876 | { | ||
| 1877 | int i; | ||
| 1878 | char name[GXIO_MPIPE_LINK_NAME_LEN]; | ||
| 1879 | uint8_t mac[6]; | ||
| 1880 | |||
| 1881 | pr_info("Tilera Network Driver\n"); | ||
| 1882 | |||
| 1883 | mutex_init(&tile_net_devs_for_channel_mutex); | ||
| 1884 | |||
| 1885 | /* Initialize each CPU. */ | ||
| 1886 | on_each_cpu(tile_net_init_module_percpu, NULL, 1); | ||
| 1887 | |||
| 1888 | /* Find out what devices we have, and initialize them. */ | ||
| 1889 | for (i = 0; gxio_mpipe_link_enumerate_mac(i, name, mac) >= 0; i++) | ||
| 1890 | tile_net_dev_init(name, mac); | ||
| 1891 | |||
| 1892 | if (!network_cpus_init()) | ||
| 1893 | network_cpus_map = *cpu_online_mask; | ||
| 1894 | |||
| 1895 | return 0; | ||
| 1896 | } | ||
| 1897 | |||
| 1898 | module_init(tile_net_init_module); | ||
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index 4ffcd57b011b..2857ab078aac 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h | |||
| @@ -478,6 +478,7 @@ struct netvsc_device { | |||
| 478 | u32 nvsp_version; | 478 | u32 nvsp_version; |
| 479 | 479 | ||
| 480 | atomic_t num_outstanding_sends; | 480 | atomic_t num_outstanding_sends; |
| 481 | wait_queue_head_t wait_drain; | ||
| 481 | bool start_remove; | 482 | bool start_remove; |
| 482 | bool destroy; | 483 | bool destroy; |
| 483 | /* | 484 | /* |
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 8b919471472f..0c569831db5a 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c | |||
| @@ -42,6 +42,7 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device) | |||
| 42 | if (!net_device) | 42 | if (!net_device) |
| 43 | return NULL; | 43 | return NULL; |
| 44 | 44 | ||
| 45 | init_waitqueue_head(&net_device->wait_drain); | ||
| 45 | net_device->start_remove = false; | 46 | net_device->start_remove = false; |
| 46 | net_device->destroy = false; | 47 | net_device->destroy = false; |
| 47 | net_device->dev = device; | 48 | net_device->dev = device; |
| @@ -387,12 +388,8 @@ int netvsc_device_remove(struct hv_device *device) | |||
| 387 | spin_unlock_irqrestore(&device->channel->inbound_lock, flags); | 388 | spin_unlock_irqrestore(&device->channel->inbound_lock, flags); |
| 388 | 389 | ||
| 389 | /* Wait for all send completions */ | 390 | /* Wait for all send completions */ |
| 390 | while (atomic_read(&net_device->num_outstanding_sends)) { | 391 | wait_event(net_device->wait_drain, |
| 391 | dev_info(&device->device, | 392 | atomic_read(&net_device->num_outstanding_sends) == 0); |
| 392 | "waiting for %d requests to complete...\n", | ||
| 393 | atomic_read(&net_device->num_outstanding_sends)); | ||
| 394 | udelay(100); | ||
| 395 | } | ||
| 396 | 393 | ||
| 397 | netvsc_disconnect_vsp(net_device); | 394 | netvsc_disconnect_vsp(net_device); |
| 398 | 395 | ||
| @@ -486,6 +483,9 @@ static void netvsc_send_completion(struct hv_device *device, | |||
| 486 | num_outstanding_sends = | 483 | num_outstanding_sends = |
| 487 | atomic_dec_return(&net_device->num_outstanding_sends); | 484 | atomic_dec_return(&net_device->num_outstanding_sends); |
| 488 | 485 | ||
| 486 | if (net_device->destroy && num_outstanding_sends == 0) | ||
| 487 | wake_up(&net_device->wait_drain); | ||
| 488 | |||
| 489 | if (netif_queue_stopped(ndev) && !net_device->start_remove && | 489 | if (netif_queue_stopped(ndev) && !net_device->start_remove && |
| 490 | (hv_ringbuf_avail_percent(&device->channel->outbound) | 490 | (hv_ringbuf_avail_percent(&device->channel->outbound) |
| 491 | > RING_AVAIL_PERCENT_HIWATER || | 491 | > RING_AVAIL_PERCENT_HIWATER || |
diff --git a/drivers/net/phy/icplus.c b/drivers/net/phy/icplus.c index 5ac46f5226f3..47f8e8939266 100644 --- a/drivers/net/phy/icplus.c +++ b/drivers/net/phy/icplus.c | |||
| @@ -41,6 +41,8 @@ MODULE_LICENSE("GPL"); | |||
| 41 | #define IP1001_APS_ON 11 /* IP1001 APS Mode bit */ | 41 | #define IP1001_APS_ON 11 /* IP1001 APS Mode bit */ |
| 42 | #define IP101A_G_APS_ON 2 /* IP101A/G APS Mode bit */ | 42 | #define IP101A_G_APS_ON 2 /* IP101A/G APS Mode bit */ |
| 43 | #define IP101A_G_IRQ_CONF_STATUS 0x11 /* Conf Info IRQ & Status Reg */ | 43 | #define IP101A_G_IRQ_CONF_STATUS 0x11 /* Conf Info IRQ & Status Reg */ |
| 44 | #define IP101A_G_IRQ_PIN_USED (1<<15) /* INTR pin used */ | ||
| 45 | #define IP101A_G_IRQ_DEFAULT IP101A_G_IRQ_PIN_USED | ||
| 44 | 46 | ||
| 45 | static int ip175c_config_init(struct phy_device *phydev) | 47 | static int ip175c_config_init(struct phy_device *phydev) |
| 46 | { | 48 | { |
| @@ -136,6 +138,11 @@ static int ip1001_config_init(struct phy_device *phydev) | |||
| 136 | if (c < 0) | 138 | if (c < 0) |
| 137 | return c; | 139 | return c; |
| 138 | 140 | ||
| 141 | /* INTR pin used: speed/link/duplex will cause an interrupt */ | ||
| 142 | c = phy_write(phydev, IP101A_G_IRQ_CONF_STATUS, IP101A_G_IRQ_DEFAULT); | ||
| 143 | if (c < 0) | ||
| 144 | return c; | ||
| 145 | |||
| 139 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII) { | 146 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII) { |
| 140 | /* Additional delay (2ns) used to adjust RX clock phase | 147 | /* Additional delay (2ns) used to adjust RX clock phase |
| 141 | * at RGMII interface */ | 148 | * at RGMII interface */ |
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 683ef1ce5519..5061608f408c 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c | |||
| @@ -96,7 +96,7 @@ static int of_mdio_bus_match(struct device *dev, void *mdio_bus_np) | |||
| 96 | } | 96 | } |
| 97 | /** | 97 | /** |
| 98 | * of_mdio_find_bus - Given an mii_bus node, find the mii_bus. | 98 | * of_mdio_find_bus - Given an mii_bus node, find the mii_bus. |
| 99 | * @mdio_np: Pointer to the mii_bus. | 99 | * @mdio_bus_np: Pointer to the mii_bus. |
| 100 | * | 100 | * |
| 101 | * Returns a pointer to the mii_bus, or NULL if none found. | 101 | * Returns a pointer to the mii_bus, or NULL if none found. |
| 102 | * | 102 | * |
diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c index 3faef5670d1f..d75d1f56becf 100644 --- a/drivers/net/usb/sierra_net.c +++ b/drivers/net/usb/sierra_net.c | |||
| @@ -946,7 +946,7 @@ struct sk_buff *sierra_net_tx_fixup(struct usbnet *dev, struct sk_buff *skb, | |||
| 946 | } | 946 | } |
| 947 | 947 | ||
| 948 | static const u8 sierra_net_ifnum_list[] = { 7, 10, 11 }; | 948 | static const u8 sierra_net_ifnum_list[] = { 7, 10, 11 }; |
| 949 | static const struct sierra_net_info_data sierra_net_info_data_68A3 = { | 949 | static const struct sierra_net_info_data sierra_net_info_data_direct_ip = { |
| 950 | .rx_urb_size = 8 * 1024, | 950 | .rx_urb_size = 8 * 1024, |
| 951 | .whitelist = { | 951 | .whitelist = { |
| 952 | .infolen = ARRAY_SIZE(sierra_net_ifnum_list), | 952 | .infolen = ARRAY_SIZE(sierra_net_ifnum_list), |
| @@ -954,7 +954,7 @@ static const struct sierra_net_info_data sierra_net_info_data_68A3 = { | |||
| 954 | } | 954 | } |
| 955 | }; | 955 | }; |
| 956 | 956 | ||
| 957 | static const struct driver_info sierra_net_info_68A3 = { | 957 | static const struct driver_info sierra_net_info_direct_ip = { |
| 958 | .description = "Sierra Wireless USB-to-WWAN Modem", | 958 | .description = "Sierra Wireless USB-to-WWAN Modem", |
| 959 | .flags = FLAG_WWAN | FLAG_SEND_ZLP, | 959 | .flags = FLAG_WWAN | FLAG_SEND_ZLP, |
| 960 | .bind = sierra_net_bind, | 960 | .bind = sierra_net_bind, |
| @@ -962,12 +962,18 @@ static const struct driver_info sierra_net_info_68A3 = { | |||
| 962 | .status = sierra_net_status, | 962 | .status = sierra_net_status, |
| 963 | .rx_fixup = sierra_net_rx_fixup, | 963 | .rx_fixup = sierra_net_rx_fixup, |
| 964 | .tx_fixup = sierra_net_tx_fixup, | 964 | .tx_fixup = sierra_net_tx_fixup, |
| 965 | .data = (unsigned long)&sierra_net_info_data_68A3, | 965 | .data = (unsigned long)&sierra_net_info_data_direct_ip, |
| 966 | }; | 966 | }; |
| 967 | 967 | ||
| 968 | static const struct usb_device_id products[] = { | 968 | static const struct usb_device_id products[] = { |
| 969 | {USB_DEVICE(0x1199, 0x68A3), /* Sierra Wireless USB-to-WWAN modem */ | 969 | {USB_DEVICE(0x1199, 0x68A3), /* Sierra Wireless USB-to-WWAN modem */ |
| 970 | .driver_info = (unsigned long) &sierra_net_info_68A3}, | 970 | .driver_info = (unsigned long) &sierra_net_info_direct_ip}, |
| 971 | {USB_DEVICE(0x0F3D, 0x68A3), /* AT&T Direct IP modem */ | ||
| 972 | .driver_info = (unsigned long) &sierra_net_info_direct_ip}, | ||
| 973 | {USB_DEVICE(0x1199, 0x68AA), /* Sierra Wireless Direct IP LTE modem */ | ||
| 974 | .driver_info = (unsigned long) &sierra_net_info_direct_ip}, | ||
| 975 | {USB_DEVICE(0x0F3D, 0x68AA), /* AT&T Direct IP LTE modem */ | ||
| 976 | .driver_info = (unsigned long) &sierra_net_info_direct_ip}, | ||
| 971 | 977 | ||
| 972 | {}, /* last item */ | 978 | {}, /* last item */ |
| 973 | }; | 979 | }; |
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 5214b1eceb95..f18149ae2588 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c | |||
| @@ -42,7 +42,8 @@ module_param(gso, bool, 0444); | |||
| 42 | #define VIRTNET_DRIVER_VERSION "1.0.0" | 42 | #define VIRTNET_DRIVER_VERSION "1.0.0" |
| 43 | 43 | ||
| 44 | struct virtnet_stats { | 44 | struct virtnet_stats { |
| 45 | struct u64_stats_sync syncp; | 45 | struct u64_stats_sync tx_syncp; |
| 46 | struct u64_stats_sync rx_syncp; | ||
| 46 | u64 tx_bytes; | 47 | u64 tx_bytes; |
| 47 | u64 tx_packets; | 48 | u64 tx_packets; |
| 48 | 49 | ||
| @@ -300,10 +301,10 @@ static void receive_buf(struct net_device *dev, void *buf, unsigned int len) | |||
| 300 | 301 | ||
| 301 | hdr = skb_vnet_hdr(skb); | 302 | hdr = skb_vnet_hdr(skb); |
| 302 | 303 | ||
| 303 | u64_stats_update_begin(&stats->syncp); | 304 | u64_stats_update_begin(&stats->rx_syncp); |
| 304 | stats->rx_bytes += skb->len; | 305 | stats->rx_bytes += skb->len; |
| 305 | stats->rx_packets++; | 306 | stats->rx_packets++; |
| 306 | u64_stats_update_end(&stats->syncp); | 307 | u64_stats_update_end(&stats->rx_syncp); |
| 307 | 308 | ||
| 308 | if (hdr->hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) { | 309 | if (hdr->hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) { |
| 309 | pr_debug("Needs csum!\n"); | 310 | pr_debug("Needs csum!\n"); |
| @@ -565,10 +566,10 @@ static unsigned int free_old_xmit_skbs(struct virtnet_info *vi) | |||
| 565 | while ((skb = virtqueue_get_buf(vi->svq, &len)) != NULL) { | 566 | while ((skb = virtqueue_get_buf(vi->svq, &len)) != NULL) { |
| 566 | pr_debug("Sent skb %p\n", skb); | 567 | pr_debug("Sent skb %p\n", skb); |
| 567 | 568 | ||
| 568 | u64_stats_update_begin(&stats->syncp); | 569 | u64_stats_update_begin(&stats->tx_syncp); |
| 569 | stats->tx_bytes += skb->len; | 570 | stats->tx_bytes += skb->len; |
| 570 | stats->tx_packets++; | 571 | stats->tx_packets++; |
| 571 | u64_stats_update_end(&stats->syncp); | 572 | u64_stats_update_end(&stats->tx_syncp); |
| 572 | 573 | ||
| 573 | tot_sgs += skb_vnet_hdr(skb)->num_sg; | 574 | tot_sgs += skb_vnet_hdr(skb)->num_sg; |
| 574 | dev_kfree_skb_any(skb); | 575 | dev_kfree_skb_any(skb); |
| @@ -703,12 +704,16 @@ static struct rtnl_link_stats64 *virtnet_stats(struct net_device *dev, | |||
| 703 | u64 tpackets, tbytes, rpackets, rbytes; | 704 | u64 tpackets, tbytes, rpackets, rbytes; |
| 704 | 705 | ||
| 705 | do { | 706 | do { |
| 706 | start = u64_stats_fetch_begin(&stats->syncp); | 707 | start = u64_stats_fetch_begin(&stats->tx_syncp); |
| 707 | tpackets = stats->tx_packets; | 708 | tpackets = stats->tx_packets; |
| 708 | tbytes = stats->tx_bytes; | 709 | tbytes = stats->tx_bytes; |
| 710 | } while (u64_stats_fetch_retry(&stats->tx_syncp, start)); | ||
| 711 | |||
| 712 | do { | ||
| 713 | start = u64_stats_fetch_begin(&stats->rx_syncp); | ||
| 709 | rpackets = stats->rx_packets; | 714 | rpackets = stats->rx_packets; |
| 710 | rbytes = stats->rx_bytes; | 715 | rbytes = stats->rx_bytes; |
| 711 | } while (u64_stats_fetch_retry(&stats->syncp, start)); | 716 | } while (u64_stats_fetch_retry(&stats->rx_syncp, start)); |
| 712 | 717 | ||
| 713 | tot->rx_packets += rpackets; | 718 | tot->rx_packets += rpackets; |
| 714 | tot->tx_packets += tpackets; | 719 | tot->tx_packets += tpackets; |
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h index 67c13af6f206..c06b6cb5c91e 100644 --- a/drivers/net/wireless/b43/b43.h +++ b/drivers/net/wireless/b43/b43.h | |||
| @@ -877,6 +877,10 @@ struct b43_wl { | |||
| 877 | * from the mac80211 subsystem. */ | 877 | * from the mac80211 subsystem. */ |
| 878 | u16 mac80211_initially_registered_queues; | 878 | u16 mac80211_initially_registered_queues; |
| 879 | 879 | ||
| 880 | /* Set this if we call ieee80211_register_hw() and check if we call | ||
| 881 | * ieee80211_unregister_hw(). */ | ||
| 882 | bool hw_registred; | ||
| 883 | |||
| 880 | /* We can only have one operating interface (802.11 core) | 884 | /* We can only have one operating interface (802.11 core) |
| 881 | * at a time. General information about this interface follows. | 885 | * at a time. General information about this interface follows. |
| 882 | */ | 886 | */ |
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index 5a39b226b2e3..acd03a4f9730 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c | |||
| @@ -2437,6 +2437,7 @@ start_ieee80211: | |||
| 2437 | err = ieee80211_register_hw(wl->hw); | 2437 | err = ieee80211_register_hw(wl->hw); |
| 2438 | if (err) | 2438 | if (err) |
| 2439 | goto err_one_core_detach; | 2439 | goto err_one_core_detach; |
| 2440 | wl->hw_registred = true; | ||
| 2440 | b43_leds_register(wl->current_dev); | 2441 | b43_leds_register(wl->current_dev); |
| 2441 | goto out; | 2442 | goto out; |
| 2442 | 2443 | ||
| @@ -5299,6 +5300,7 @@ static struct b43_wl *b43_wireless_init(struct b43_bus_dev *dev) | |||
| 5299 | 5300 | ||
| 5300 | hw->queues = modparam_qos ? B43_QOS_QUEUE_NUM : 1; | 5301 | hw->queues = modparam_qos ? B43_QOS_QUEUE_NUM : 1; |
| 5301 | wl->mac80211_initially_registered_queues = hw->queues; | 5302 | wl->mac80211_initially_registered_queues = hw->queues; |
| 5303 | wl->hw_registred = false; | ||
| 5302 | hw->max_rates = 2; | 5304 | hw->max_rates = 2; |
| 5303 | SET_IEEE80211_DEV(hw, dev->dev); | 5305 | SET_IEEE80211_DEV(hw, dev->dev); |
| 5304 | if (is_valid_ether_addr(sprom->et1mac)) | 5306 | if (is_valid_ether_addr(sprom->et1mac)) |
| @@ -5370,12 +5372,15 @@ static void b43_bcma_remove(struct bcma_device *core) | |||
| 5370 | * as the ieee80211 unreg will destroy the workqueue. */ | 5372 | * as the ieee80211 unreg will destroy the workqueue. */ |
| 5371 | cancel_work_sync(&wldev->restart_work); | 5373 | cancel_work_sync(&wldev->restart_work); |
| 5372 | 5374 | ||
| 5373 | /* Restore the queues count before unregistering, because firmware detect | 5375 | B43_WARN_ON(!wl); |
| 5374 | * might have modified it. Restoring is important, so the networking | 5376 | if (wl->current_dev == wldev && wl->hw_registred) { |
| 5375 | * stack can properly free resources. */ | 5377 | /* Restore the queues count before unregistering, because firmware detect |
| 5376 | wl->hw->queues = wl->mac80211_initially_registered_queues; | 5378 | * might have modified it. Restoring is important, so the networking |
| 5377 | b43_leds_stop(wldev); | 5379 | * stack can properly free resources. */ |
| 5378 | ieee80211_unregister_hw(wl->hw); | 5380 | wl->hw->queues = wl->mac80211_initially_registered_queues; |
| 5381 | b43_leds_stop(wldev); | ||
| 5382 | ieee80211_unregister_hw(wl->hw); | ||
| 5383 | } | ||
| 5379 | 5384 | ||
| 5380 | b43_one_core_detach(wldev->dev); | 5385 | b43_one_core_detach(wldev->dev); |
| 5381 | 5386 | ||
| @@ -5446,7 +5451,7 @@ static void b43_ssb_remove(struct ssb_device *sdev) | |||
| 5446 | cancel_work_sync(&wldev->restart_work); | 5451 | cancel_work_sync(&wldev->restart_work); |
| 5447 | 5452 | ||
| 5448 | B43_WARN_ON(!wl); | 5453 | B43_WARN_ON(!wl); |
| 5449 | if (wl->current_dev == wldev) { | 5454 | if (wl->current_dev == wldev && wl->hw_registred) { |
| 5450 | /* Restore the queues count before unregistering, because firmware detect | 5455 | /* Restore the queues count before unregistering, because firmware detect |
| 5451 | * might have modified it. Restoring is important, so the networking | 5456 | * might have modified it. Restoring is important, so the networking |
| 5452 | * stack can properly free resources. */ | 5457 | * stack can properly free resources. */ |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c index e2480d196276..8e7e6928c936 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c | |||
| @@ -89,9 +89,9 @@ int brcmf_sdio_intr_register(struct brcmf_sdio_dev *sdiodev) | |||
| 89 | data |= 1 << SDIO_FUNC_1 | 1 << SDIO_FUNC_2 | 1; | 89 | data |= 1 << SDIO_FUNC_1 | 1 << SDIO_FUNC_2 | 1; |
| 90 | brcmf_sdio_regwb(sdiodev, SDIO_CCCR_IENx, data, &ret); | 90 | brcmf_sdio_regwb(sdiodev, SDIO_CCCR_IENx, data, &ret); |
| 91 | 91 | ||
| 92 | /* redirect, configure ane enable io for interrupt signal */ | 92 | /* redirect, configure and enable io for interrupt signal */ |
| 93 | data = SDIO_SEPINT_MASK | SDIO_SEPINT_OE; | 93 | data = SDIO_SEPINT_MASK | SDIO_SEPINT_OE; |
| 94 | if (sdiodev->irq_flags | IRQF_TRIGGER_HIGH) | 94 | if (sdiodev->irq_flags & IRQF_TRIGGER_HIGH) |
| 95 | data |= SDIO_SEPINT_ACT_HI; | 95 | data |= SDIO_SEPINT_ACT_HI; |
| 96 | brcmf_sdio_regwb(sdiodev, SDIO_CCCR_BRCM_SEPINT, data, &ret); | 96 | brcmf_sdio_regwb(sdiodev, SDIO_CCCR_BRCM_SEPINT, data, &ret); |
| 97 | 97 | ||
diff --git a/drivers/net/wireless/ipw2x00/ipw2100.c b/drivers/net/wireless/ipw2x00/ipw2100.c index 9cfae0c08707..95aa8e1683ec 100644 --- a/drivers/net/wireless/ipw2x00/ipw2100.c +++ b/drivers/net/wireless/ipw2x00/ipw2100.c | |||
| @@ -1903,14 +1903,6 @@ static void ipw2100_down(struct ipw2100_priv *priv) | |||
| 1903 | netif_stop_queue(priv->net_dev); | 1903 | netif_stop_queue(priv->net_dev); |
| 1904 | } | 1904 | } |
| 1905 | 1905 | ||
| 1906 | /* Called by register_netdev() */ | ||
| 1907 | static int ipw2100_net_init(struct net_device *dev) | ||
| 1908 | { | ||
| 1909 | struct ipw2100_priv *priv = libipw_priv(dev); | ||
| 1910 | |||
| 1911 | return ipw2100_up(priv, 1); | ||
| 1912 | } | ||
| 1913 | |||
| 1914 | static int ipw2100_wdev_init(struct net_device *dev) | 1906 | static int ipw2100_wdev_init(struct net_device *dev) |
| 1915 | { | 1907 | { |
| 1916 | struct ipw2100_priv *priv = libipw_priv(dev); | 1908 | struct ipw2100_priv *priv = libipw_priv(dev); |
| @@ -6087,7 +6079,6 @@ static const struct net_device_ops ipw2100_netdev_ops = { | |||
| 6087 | .ndo_stop = ipw2100_close, | 6079 | .ndo_stop = ipw2100_close, |
| 6088 | .ndo_start_xmit = libipw_xmit, | 6080 | .ndo_start_xmit = libipw_xmit, |
| 6089 | .ndo_change_mtu = libipw_change_mtu, | 6081 | .ndo_change_mtu = libipw_change_mtu, |
| 6090 | .ndo_init = ipw2100_net_init, | ||
| 6091 | .ndo_tx_timeout = ipw2100_tx_timeout, | 6082 | .ndo_tx_timeout = ipw2100_tx_timeout, |
| 6092 | .ndo_set_mac_address = ipw2100_set_address, | 6083 | .ndo_set_mac_address = ipw2100_set_address, |
| 6093 | .ndo_validate_addr = eth_validate_addr, | 6084 | .ndo_validate_addr = eth_validate_addr, |
| @@ -6329,6 +6320,10 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev, | |||
| 6329 | printk(KERN_INFO DRV_NAME | 6320 | printk(KERN_INFO DRV_NAME |
| 6330 | ": Detected Intel PRO/Wireless 2100 Network Connection\n"); | 6321 | ": Detected Intel PRO/Wireless 2100 Network Connection\n"); |
| 6331 | 6322 | ||
| 6323 | err = ipw2100_up(priv, 1); | ||
| 6324 | if (err) | ||
| 6325 | goto fail; | ||
| 6326 | |||
| 6332 | err = ipw2100_wdev_init(dev); | 6327 | err = ipw2100_wdev_init(dev); |
| 6333 | if (err) | 6328 | if (err) |
| 6334 | goto fail; | 6329 | goto fail; |
| @@ -6338,12 +6333,7 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev, | |||
| 6338 | * network device we would call ipw2100_up. This introduced a race | 6333 | * network device we would call ipw2100_up. This introduced a race |
| 6339 | * condition with newer hotplug configurations (network was coming | 6334 | * condition with newer hotplug configurations (network was coming |
| 6340 | * up and making calls before the device was initialized). | 6335 | * up and making calls before the device was initialized). |
| 6341 | * | 6336 | */ |
| 6342 | * If we called ipw2100_up before we registered the device, then the | ||
| 6343 | * device name wasn't registered. So, we instead use the net_dev->init | ||
| 6344 | * member to call a function that then just turns and calls ipw2100_up. | ||
| 6345 | * net_dev->init is called after name allocation but before the | ||
| 6346 | * notifier chain is called */ | ||
| 6347 | err = register_netdev(dev); | 6337 | err = register_netdev(dev); |
| 6348 | if (err) { | 6338 | if (err) { |
| 6349 | printk(KERN_WARNING DRV_NAME | 6339 | printk(KERN_WARNING DRV_NAME |
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index 19f7ee84ae89..e5e8ada4aaf6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c | |||
| @@ -35,17 +35,20 @@ | |||
| 35 | #define IWL6000_UCODE_API_MAX 6 | 35 | #define IWL6000_UCODE_API_MAX 6 |
| 36 | #define IWL6050_UCODE_API_MAX 5 | 36 | #define IWL6050_UCODE_API_MAX 5 |
| 37 | #define IWL6000G2_UCODE_API_MAX 6 | 37 | #define IWL6000G2_UCODE_API_MAX 6 |
| 38 | #define IWL6035_UCODE_API_MAX 6 | ||
| 38 | 39 | ||
| 39 | /* Oldest version we won't warn about */ | 40 | /* Oldest version we won't warn about */ |
| 40 | #define IWL6000_UCODE_API_OK 4 | 41 | #define IWL6000_UCODE_API_OK 4 |
| 41 | #define IWL6000G2_UCODE_API_OK 5 | 42 | #define IWL6000G2_UCODE_API_OK 5 |
| 42 | #define IWL6050_UCODE_API_OK 5 | 43 | #define IWL6050_UCODE_API_OK 5 |
| 43 | #define IWL6000G2B_UCODE_API_OK 6 | 44 | #define IWL6000G2B_UCODE_API_OK 6 |
| 45 | #define IWL6035_UCODE_API_OK 6 | ||
| 44 | 46 | ||
| 45 | /* Lowest firmware API version supported */ | 47 | /* Lowest firmware API version supported */ |
| 46 | #define IWL6000_UCODE_API_MIN 4 | 48 | #define IWL6000_UCODE_API_MIN 4 |
| 47 | #define IWL6050_UCODE_API_MIN 4 | 49 | #define IWL6050_UCODE_API_MIN 4 |
| 48 | #define IWL6000G2_UCODE_API_MIN 4 | 50 | #define IWL6000G2_UCODE_API_MIN 5 |
| 51 | #define IWL6035_UCODE_API_MIN 6 | ||
| 49 | 52 | ||
| 50 | /* EEPROM versions */ | 53 | /* EEPROM versions */ |
| 51 | #define EEPROM_6000_TX_POWER_VERSION (4) | 54 | #define EEPROM_6000_TX_POWER_VERSION (4) |
| @@ -227,9 +230,25 @@ const struct iwl_cfg iwl6030_2bg_cfg = { | |||
| 227 | IWL_DEVICE_6030, | 230 | IWL_DEVICE_6030, |
| 228 | }; | 231 | }; |
| 229 | 232 | ||
| 233 | #define IWL_DEVICE_6035 \ | ||
| 234 | .fw_name_pre = IWL6030_FW_PRE, \ | ||
| 235 | .ucode_api_max = IWL6035_UCODE_API_MAX, \ | ||
| 236 | .ucode_api_ok = IWL6035_UCODE_API_OK, \ | ||
| 237 | .ucode_api_min = IWL6035_UCODE_API_MIN, \ | ||
| 238 | .device_family = IWL_DEVICE_FAMILY_6030, \ | ||
| 239 | .max_inst_size = IWL60_RTC_INST_SIZE, \ | ||
| 240 | .max_data_size = IWL60_RTC_DATA_SIZE, \ | ||
| 241 | .eeprom_ver = EEPROM_6030_EEPROM_VERSION, \ | ||
| 242 | .eeprom_calib_ver = EEPROM_6030_TX_POWER_VERSION, \ | ||
| 243 | .base_params = &iwl6000_g2_base_params, \ | ||
| 244 | .bt_params = &iwl6000_bt_params, \ | ||
| 245 | .need_temp_offset_calib = true, \ | ||
| 246 | .led_mode = IWL_LED_RF_STATE, \ | ||
| 247 | .adv_pm = true | ||
| 248 | |||
| 230 | const struct iwl_cfg iwl6035_2agn_cfg = { | 249 | const struct iwl_cfg iwl6035_2agn_cfg = { |
| 231 | .name = "Intel(R) Centrino(R) Advanced-N 6235 AGN", | 250 | .name = "Intel(R) Centrino(R) Advanced-N 6235 AGN", |
| 232 | IWL_DEVICE_6030, | 251 | IWL_DEVICE_6035, |
| 233 | .ht_params = &iwl6000_ht_params, | 252 | .ht_params = &iwl6000_ht_params, |
| 234 | }; | 253 | }; |
| 235 | 254 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index aea07aab3c9e..eb6a8eaf42fc 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c | |||
| @@ -1267,7 +1267,7 @@ int iwl_remove_dynamic_key(struct iwl_priv *priv, | |||
| 1267 | key_flags |= STA_KEY_MULTICAST_MSK; | 1267 | key_flags |= STA_KEY_MULTICAST_MSK; |
| 1268 | 1268 | ||
| 1269 | sta_cmd.key.key_flags = key_flags; | 1269 | sta_cmd.key.key_flags = key_flags; |
| 1270 | sta_cmd.key.key_offset = WEP_INVALID_OFFSET; | 1270 | sta_cmd.key.key_offset = keyconf->hw_key_idx; |
| 1271 | sta_cmd.sta.modify_mask = STA_MODIFY_KEY_MASK; | 1271 | sta_cmd.sta.modify_mask = STA_MODIFY_KEY_MASK; |
| 1272 | sta_cmd.mode = STA_CONTROL_MODIFY_MSK; | 1272 | sta_cmd.mode = STA_CONTROL_MODIFY_MSK; |
| 1273 | 1273 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c index d742900969ea..fac67a526a30 100644 --- a/drivers/net/wireless/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/iwlwifi/iwl-drv.c | |||
| @@ -861,13 +861,18 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) | |||
| 861 | 861 | ||
| 862 | /* We have our copies now, allow OS release its copies */ | 862 | /* We have our copies now, allow OS release its copies */ |
| 863 | release_firmware(ucode_raw); | 863 | release_firmware(ucode_raw); |
| 864 | complete(&drv->request_firmware_complete); | ||
| 865 | 864 | ||
| 866 | drv->op_mode = iwl_dvm_ops.start(drv->trans, drv->cfg, &drv->fw); | 865 | drv->op_mode = iwl_dvm_ops.start(drv->trans, drv->cfg, &drv->fw); |
| 867 | 866 | ||
| 868 | if (!drv->op_mode) | 867 | if (!drv->op_mode) |
| 869 | goto out_free_fw; | 868 | goto out_unbind; |
| 870 | 869 | ||
| 870 | /* | ||
| 871 | * Complete the firmware request last so that | ||
| 872 | * a driver unbind (stop) doesn't run while we | ||
| 873 | * are doing the start() above. | ||
| 874 | */ | ||
| 875 | complete(&drv->request_firmware_complete); | ||
| 871 | return; | 876 | return; |
| 872 | 877 | ||
| 873 | try_again: | 878 | try_again: |
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c index 50c58911e718..b8e2b223ac36 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c | |||
| @@ -568,28 +568,28 @@ static int iwl_find_otp_image(struct iwl_trans *trans, | |||
| 568 | * iwl_get_max_txpower_avg - get the highest tx power from all chains. | 568 | * iwl_get_max_txpower_avg - get the highest tx power from all chains. |
| 569 | * find the highest tx power from all chains for the channel | 569 | * find the highest tx power from all chains for the channel |
| 570 | */ | 570 | */ |
| 571 | static s8 iwl_get_max_txpower_avg(const struct iwl_cfg *cfg, | 571 | static s8 iwl_get_max_txpower_avg(struct iwl_priv *priv, |
| 572 | struct iwl_eeprom_enhanced_txpwr *enhanced_txpower, | 572 | struct iwl_eeprom_enhanced_txpwr *enhanced_txpower, |
| 573 | int element, s8 *max_txpower_in_half_dbm) | 573 | int element, s8 *max_txpower_in_half_dbm) |
| 574 | { | 574 | { |
| 575 | s8 max_txpower_avg = 0; /* (dBm) */ | 575 | s8 max_txpower_avg = 0; /* (dBm) */ |
| 576 | 576 | ||
| 577 | /* Take the highest tx power from any valid chains */ | 577 | /* Take the highest tx power from any valid chains */ |
| 578 | if ((cfg->valid_tx_ant & ANT_A) && | 578 | if ((priv->hw_params.valid_tx_ant & ANT_A) && |
| 579 | (enhanced_txpower[element].chain_a_max > max_txpower_avg)) | 579 | (enhanced_txpower[element].chain_a_max > max_txpower_avg)) |
| 580 | max_txpower_avg = enhanced_txpower[element].chain_a_max; | 580 | max_txpower_avg = enhanced_txpower[element].chain_a_max; |
| 581 | if ((cfg->valid_tx_ant & ANT_B) && | 581 | if ((priv->hw_params.valid_tx_ant & ANT_B) && |
| 582 | (enhanced_txpower[element].chain_b_max > max_txpower_avg)) | 582 | (enhanced_txpower[element].chain_b_max > max_txpower_avg)) |
| 583 | max_txpower_avg = enhanced_txpower[element].chain_b_max; | 583 | max_txpower_avg = enhanced_txpower[element].chain_b_max; |
| 584 | if ((cfg->valid_tx_ant & ANT_C) && | 584 | if ((priv->hw_params.valid_tx_ant & ANT_C) && |
| 585 | (enhanced_txpower[element].chain_c_max > max_txpower_avg)) | 585 | (enhanced_txpower[element].chain_c_max > max_txpower_avg)) |
| 586 | max_txpower_avg = enhanced_txpower[element].chain_c_max; | 586 | max_txpower_avg = enhanced_txpower[element].chain_c_max; |
| 587 | if (((cfg->valid_tx_ant == ANT_AB) | | 587 | if (((priv->hw_params.valid_tx_ant == ANT_AB) | |
| 588 | (cfg->valid_tx_ant == ANT_BC) | | 588 | (priv->hw_params.valid_tx_ant == ANT_BC) | |
| 589 | (cfg->valid_tx_ant == ANT_AC)) && | 589 | (priv->hw_params.valid_tx_ant == ANT_AC)) && |
| 590 | (enhanced_txpower[element].mimo2_max > max_txpower_avg)) | 590 | (enhanced_txpower[element].mimo2_max > max_txpower_avg)) |
| 591 | max_txpower_avg = enhanced_txpower[element].mimo2_max; | 591 | max_txpower_avg = enhanced_txpower[element].mimo2_max; |
| 592 | if ((cfg->valid_tx_ant == ANT_ABC) && | 592 | if ((priv->hw_params.valid_tx_ant == ANT_ABC) && |
| 593 | (enhanced_txpower[element].mimo3_max > max_txpower_avg)) | 593 | (enhanced_txpower[element].mimo3_max > max_txpower_avg)) |
| 594 | max_txpower_avg = enhanced_txpower[element].mimo3_max; | 594 | max_txpower_avg = enhanced_txpower[element].mimo3_max; |
| 595 | 595 | ||
| @@ -691,7 +691,7 @@ static void iwl_eeprom_enhanced_txpower(struct iwl_priv *priv) | |||
| 691 | ((txp->delta_20_in_40 & 0xf0) >> 4), | 691 | ((txp->delta_20_in_40 & 0xf0) >> 4), |
| 692 | (txp->delta_20_in_40 & 0x0f)); | 692 | (txp->delta_20_in_40 & 0x0f)); |
| 693 | 693 | ||
| 694 | max_txp_avg = iwl_get_max_txpower_avg(priv->cfg, txp_array, idx, | 694 | max_txp_avg = iwl_get_max_txpower_avg(priv, txp_array, idx, |
| 695 | &max_txp_avg_halfdbm); | 695 | &max_txp_avg_halfdbm); |
| 696 | 696 | ||
| 697 | /* | 697 | /* |
diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index ab2f4d7500a4..3ee23134c02b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c | |||
| @@ -199,6 +199,7 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv, | |||
| 199 | WIPHY_FLAG_DISABLE_BEACON_HINTS | | 199 | WIPHY_FLAG_DISABLE_BEACON_HINTS | |
| 200 | WIPHY_FLAG_IBSS_RSN; | 200 | WIPHY_FLAG_IBSS_RSN; |
| 201 | 201 | ||
| 202 | #ifdef CONFIG_PM_SLEEP | ||
| 202 | if (priv->fw->img[IWL_UCODE_WOWLAN].sec[0].len && | 203 | if (priv->fw->img[IWL_UCODE_WOWLAN].sec[0].len && |
| 203 | priv->trans->ops->wowlan_suspend && | 204 | priv->trans->ops->wowlan_suspend && |
| 204 | device_can_wakeup(priv->trans->dev)) { | 205 | device_can_wakeup(priv->trans->dev)) { |
| @@ -217,6 +218,7 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv, | |||
| 217 | hw->wiphy->wowlan.pattern_max_len = | 218 | hw->wiphy->wowlan.pattern_max_len = |
| 218 | IWLAGN_WOWLAN_MAX_PATTERN_LEN; | 219 | IWLAGN_WOWLAN_MAX_PATTERN_LEN; |
| 219 | } | 220 | } |
| 221 | #endif | ||
| 220 | 222 | ||
| 221 | if (iwlwifi_mod_params.power_save) | 223 | if (iwlwifi_mod_params.power_save) |
| 222 | hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; | 224 | hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; |
| @@ -249,6 +251,7 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv, | |||
| 249 | ret = ieee80211_register_hw(priv->hw); | 251 | ret = ieee80211_register_hw(priv->hw); |
| 250 | if (ret) { | 252 | if (ret) { |
| 251 | IWL_ERR(priv, "Failed to register hw (error %d)\n", ret); | 253 | IWL_ERR(priv, "Failed to register hw (error %d)\n", ret); |
| 254 | iwl_leds_exit(priv); | ||
| 252 | return ret; | 255 | return ret; |
| 253 | } | 256 | } |
| 254 | priv->mac80211_registered = 1; | 257 | priv->mac80211_registered = 1; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-prph.h b/drivers/net/wireless/iwlwifi/iwl-prph.h index 3b1069290fa9..dfd54662e3e6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-prph.h +++ b/drivers/net/wireless/iwlwifi/iwl-prph.h | |||
| @@ -224,6 +224,7 @@ | |||
| 224 | #define SCD_TXFACT (SCD_BASE + 0x10) | 224 | #define SCD_TXFACT (SCD_BASE + 0x10) |
| 225 | #define SCD_ACTIVE (SCD_BASE + 0x14) | 225 | #define SCD_ACTIVE (SCD_BASE + 0x14) |
| 226 | #define SCD_QUEUECHAIN_SEL (SCD_BASE + 0xe8) | 226 | #define SCD_QUEUECHAIN_SEL (SCD_BASE + 0xe8) |
| 227 | #define SCD_CHAINEXT_EN (SCD_BASE + 0x244) | ||
| 227 | #define SCD_AGGR_SEL (SCD_BASE + 0x248) | 228 | #define SCD_AGGR_SEL (SCD_BASE + 0x248) |
| 228 | #define SCD_INTERRUPT_MASK (SCD_BASE + 0x108) | 229 | #define SCD_INTERRUPT_MASK (SCD_BASE + 0x108) |
| 229 | 230 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index ec6fb395b84d..79c6b91417f9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | |||
| @@ -1058,6 +1058,11 @@ static void iwl_tx_start(struct iwl_trans *trans) | |||
| 1058 | iwl_write_prph(trans, SCD_DRAM_BASE_ADDR, | 1058 | iwl_write_prph(trans, SCD_DRAM_BASE_ADDR, |
| 1059 | trans_pcie->scd_bc_tbls.dma >> 10); | 1059 | trans_pcie->scd_bc_tbls.dma >> 10); |
| 1060 | 1060 | ||
| 1061 | /* The chain extension of the SCD doesn't work well. This feature is | ||
| 1062 | * enabled by default by the HW, so we need to disable it manually. | ||
| 1063 | */ | ||
| 1064 | iwl_write_prph(trans, SCD_CHAINEXT_EN, 0); | ||
| 1065 | |||
| 1061 | /* Enable DMA channel */ | 1066 | /* Enable DMA channel */ |
| 1062 | for (chan = 0; chan < FH_TCSR_CHNL_NUM ; chan++) | 1067 | for (chan = 0; chan < FH_TCSR_CHNL_NUM ; chan++) |
| 1063 | iwl_write_direct32(trans, FH_TCSR_CHNL_TX_CONFIG_REG(chan), | 1068 | iwl_write_direct32(trans, FH_TCSR_CHNL_TX_CONFIG_REG(chan), |
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index fb787df01666..a0b7cfd34685 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c | |||
| @@ -1555,6 +1555,7 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2, | |||
| 1555 | hdr = (struct ieee80211_hdr *) skb->data; | 1555 | hdr = (struct ieee80211_hdr *) skb->data; |
| 1556 | mac80211_hwsim_monitor_ack(data2->hw, hdr->addr2); | 1556 | mac80211_hwsim_monitor_ack(data2->hw, hdr->addr2); |
| 1557 | } | 1557 | } |
| 1558 | txi->flags |= IEEE80211_TX_STAT_ACK; | ||
| 1558 | } | 1559 | } |
| 1559 | ieee80211_tx_status_irqsafe(data2->hw, skb); | 1560 | ieee80211_tx_status_irqsafe(data2->hw, skb); |
| 1560 | return 0; | 1561 | return 0; |
| @@ -1721,6 +1722,24 @@ static void hwsim_exit_netlink(void) | |||
| 1721 | "unregister family %i\n", ret); | 1722 | "unregister family %i\n", ret); |
| 1722 | } | 1723 | } |
| 1723 | 1724 | ||
| 1725 | static const struct ieee80211_iface_limit hwsim_if_limits[] = { | ||
| 1726 | { .max = 1, .types = BIT(NL80211_IFTYPE_ADHOC) }, | ||
| 1727 | { .max = 2048, .types = BIT(NL80211_IFTYPE_STATION) | | ||
| 1728 | BIT(NL80211_IFTYPE_P2P_CLIENT) | | ||
| 1729 | #ifdef CONFIG_MAC80211_MESH | ||
| 1730 | BIT(NL80211_IFTYPE_MESH_POINT) | | ||
| 1731 | #endif | ||
| 1732 | BIT(NL80211_IFTYPE_AP) | | ||
| 1733 | BIT(NL80211_IFTYPE_P2P_GO) }, | ||
| 1734 | }; | ||
| 1735 | |||
| 1736 | static const struct ieee80211_iface_combination hwsim_if_comb = { | ||
| 1737 | .limits = hwsim_if_limits, | ||
| 1738 | .n_limits = ARRAY_SIZE(hwsim_if_limits), | ||
| 1739 | .max_interfaces = 2048, | ||
| 1740 | .num_different_channels = 1, | ||
| 1741 | }; | ||
| 1742 | |||
| 1724 | static int __init init_mac80211_hwsim(void) | 1743 | static int __init init_mac80211_hwsim(void) |
| 1725 | { | 1744 | { |
| 1726 | int i, err = 0; | 1745 | int i, err = 0; |
| @@ -1782,6 +1801,9 @@ static int __init init_mac80211_hwsim(void) | |||
| 1782 | hw->wiphy->n_addresses = 2; | 1801 | hw->wiphy->n_addresses = 2; |
| 1783 | hw->wiphy->addresses = data->addresses; | 1802 | hw->wiphy->addresses = data->addresses; |
| 1784 | 1803 | ||
| 1804 | hw->wiphy->iface_combinations = &hwsim_if_comb; | ||
| 1805 | hw->wiphy->n_iface_combinations = 1; | ||
| 1806 | |||
| 1785 | if (fake_hw_scan) { | 1807 | if (fake_hw_scan) { |
| 1786 | hw->wiphy->max_scan_ssids = 255; | 1808 | hw->wiphy->max_scan_ssids = 255; |
| 1787 | hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN; | 1809 | hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN; |
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index 87671446e24b..015fec3371a0 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c | |||
| @@ -948,6 +948,19 @@ static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy, | |||
| 948 | bss_cfg->ssid.ssid_len = params->ssid_len; | 948 | bss_cfg->ssid.ssid_len = params->ssid_len; |
| 949 | } | 949 | } |
| 950 | 950 | ||
| 951 | switch (params->hidden_ssid) { | ||
| 952 | case NL80211_HIDDEN_SSID_NOT_IN_USE: | ||
| 953 | bss_cfg->bcast_ssid_ctl = 1; | ||
| 954 | break; | ||
| 955 | case NL80211_HIDDEN_SSID_ZERO_LEN: | ||
| 956 | bss_cfg->bcast_ssid_ctl = 0; | ||
| 957 | break; | ||
| 958 | case NL80211_HIDDEN_SSID_ZERO_CONTENTS: | ||
| 959 | /* firmware doesn't support this type of hidden SSID */ | ||
| 960 | default: | ||
| 961 | return -EINVAL; | ||
| 962 | } | ||
| 963 | |||
| 951 | if (mwifiex_set_secure_params(priv, bss_cfg, params)) { | 964 | if (mwifiex_set_secure_params(priv, bss_cfg, params)) { |
| 952 | kfree(bss_cfg); | 965 | kfree(bss_cfg); |
| 953 | wiphy_err(wiphy, "Failed to parse secuirty parameters!\n"); | 966 | wiphy_err(wiphy, "Failed to parse secuirty parameters!\n"); |
diff --git a/drivers/net/wireless/mwifiex/fw.h b/drivers/net/wireless/mwifiex/fw.h index 9f674bbebe65..561452a5c818 100644 --- a/drivers/net/wireless/mwifiex/fw.h +++ b/drivers/net/wireless/mwifiex/fw.h | |||
| @@ -122,6 +122,7 @@ enum MWIFIEX_802_11_PRIVACY_FILTER { | |||
| 122 | #define TLV_TYPE_CHANNELBANDLIST (PROPRIETARY_TLV_BASE_ID + 42) | 122 | #define TLV_TYPE_CHANNELBANDLIST (PROPRIETARY_TLV_BASE_ID + 42) |
| 123 | #define TLV_TYPE_UAP_BEACON_PERIOD (PROPRIETARY_TLV_BASE_ID + 44) | 123 | #define TLV_TYPE_UAP_BEACON_PERIOD (PROPRIETARY_TLV_BASE_ID + 44) |
| 124 | #define TLV_TYPE_UAP_DTIM_PERIOD (PROPRIETARY_TLV_BASE_ID + 45) | 124 | #define TLV_TYPE_UAP_DTIM_PERIOD (PROPRIETARY_TLV_BASE_ID + 45) |
| 125 | #define TLV_TYPE_UAP_BCAST_SSID (PROPRIETARY_TLV_BASE_ID + 48) | ||
| 125 | #define TLV_TYPE_UAP_RTS_THRESHOLD (PROPRIETARY_TLV_BASE_ID + 51) | 126 | #define TLV_TYPE_UAP_RTS_THRESHOLD (PROPRIETARY_TLV_BASE_ID + 51) |
| 126 | #define TLV_TYPE_UAP_WPA_PASSPHRASE (PROPRIETARY_TLV_BASE_ID + 60) | 127 | #define TLV_TYPE_UAP_WPA_PASSPHRASE (PROPRIETARY_TLV_BASE_ID + 60) |
| 127 | #define TLV_TYPE_UAP_ENCRY_PROTOCOL (PROPRIETARY_TLV_BASE_ID + 64) | 128 | #define TLV_TYPE_UAP_ENCRY_PROTOCOL (PROPRIETARY_TLV_BASE_ID + 64) |
| @@ -1209,6 +1210,11 @@ struct host_cmd_tlv_ssid { | |||
| 1209 | u8 ssid[0]; | 1210 | u8 ssid[0]; |
| 1210 | } __packed; | 1211 | } __packed; |
| 1211 | 1212 | ||
| 1213 | struct host_cmd_tlv_bcast_ssid { | ||
| 1214 | struct host_cmd_tlv tlv; | ||
| 1215 | u8 bcast_ctl; | ||
| 1216 | } __packed; | ||
| 1217 | |||
| 1212 | struct host_cmd_tlv_beacon_period { | 1218 | struct host_cmd_tlv_beacon_period { |
| 1213 | struct host_cmd_tlv tlv; | 1219 | struct host_cmd_tlv tlv; |
| 1214 | __le16 period; | 1220 | __le16 period; |
diff --git a/drivers/net/wireless/mwifiex/uap_cmd.c b/drivers/net/wireless/mwifiex/uap_cmd.c index 76dfbc42a732..8173ab66066d 100644 --- a/drivers/net/wireless/mwifiex/uap_cmd.c +++ b/drivers/net/wireless/mwifiex/uap_cmd.c | |||
| @@ -132,6 +132,7 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size) | |||
| 132 | struct host_cmd_tlv_dtim_period *dtim_period; | 132 | struct host_cmd_tlv_dtim_period *dtim_period; |
| 133 | struct host_cmd_tlv_beacon_period *beacon_period; | 133 | struct host_cmd_tlv_beacon_period *beacon_period; |
| 134 | struct host_cmd_tlv_ssid *ssid; | 134 | struct host_cmd_tlv_ssid *ssid; |
| 135 | struct host_cmd_tlv_bcast_ssid *bcast_ssid; | ||
| 135 | struct host_cmd_tlv_channel_band *chan_band; | 136 | struct host_cmd_tlv_channel_band *chan_band; |
| 136 | struct host_cmd_tlv_frag_threshold *frag_threshold; | 137 | struct host_cmd_tlv_frag_threshold *frag_threshold; |
| 137 | struct host_cmd_tlv_rts_threshold *rts_threshold; | 138 | struct host_cmd_tlv_rts_threshold *rts_threshold; |
| @@ -153,6 +154,14 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size) | |||
| 153 | cmd_size += sizeof(struct host_cmd_tlv) + | 154 | cmd_size += sizeof(struct host_cmd_tlv) + |
| 154 | bss_cfg->ssid.ssid_len; | 155 | bss_cfg->ssid.ssid_len; |
| 155 | tlv += sizeof(struct host_cmd_tlv) + bss_cfg->ssid.ssid_len; | 156 | tlv += sizeof(struct host_cmd_tlv) + bss_cfg->ssid.ssid_len; |
| 157 | |||
| 158 | bcast_ssid = (struct host_cmd_tlv_bcast_ssid *)tlv; | ||
| 159 | bcast_ssid->tlv.type = cpu_to_le16(TLV_TYPE_UAP_BCAST_SSID); | ||
| 160 | bcast_ssid->tlv.len = | ||
| 161 | cpu_to_le16(sizeof(bcast_ssid->bcast_ctl)); | ||
| 162 | bcast_ssid->bcast_ctl = bss_cfg->bcast_ssid_ctl; | ||
| 163 | cmd_size += sizeof(struct host_cmd_tlv_bcast_ssid); | ||
| 164 | tlv += sizeof(struct host_cmd_tlv_bcast_ssid); | ||
| 156 | } | 165 | } |
| 157 | if (bss_cfg->channel && bss_cfg->channel <= MAX_CHANNEL_BAND_BG) { | 166 | if (bss_cfg->channel && bss_cfg->channel <= MAX_CHANNEL_BAND_BG) { |
| 158 | chan_band = (struct host_cmd_tlv_channel_band *)tlv; | 167 | chan_band = (struct host_cmd_tlv_channel_band *)tlv; |
| @@ -416,6 +425,7 @@ int mwifiex_uap_set_channel(struct mwifiex_private *priv, int channel) | |||
| 416 | if (!bss_cfg) | 425 | if (!bss_cfg) |
| 417 | return -ENOMEM; | 426 | return -ENOMEM; |
| 418 | 427 | ||
| 428 | mwifiex_set_sys_config_invalid_data(bss_cfg); | ||
| 419 | bss_cfg->band_cfg = BAND_CONFIG_MANUAL; | 429 | bss_cfg->band_cfg = BAND_CONFIG_MANUAL; |
| 420 | bss_cfg->channel = channel; | 430 | bss_cfg->channel = channel; |
| 421 | 431 | ||
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h index ca36cccaba31..8f754025b06e 100644 --- a/drivers/net/wireless/rt2x00/rt2x00.h +++ b/drivers/net/wireless/rt2x00/rt2x00.h | |||
| @@ -396,8 +396,7 @@ struct rt2x00_intf { | |||
| 396 | * for hardware which doesn't support hardware | 396 | * for hardware which doesn't support hardware |
| 397 | * sequence counting. | 397 | * sequence counting. |
| 398 | */ | 398 | */ |
| 399 | spinlock_t seqlock; | 399 | atomic_t seqno; |
| 400 | u16 seqno; | ||
| 401 | }; | 400 | }; |
| 402 | 401 | ||
| 403 | static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif) | 402 | static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif) |
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c index b49773ef72f2..dd24b2663b5e 100644 --- a/drivers/net/wireless/rt2x00/rt2x00mac.c +++ b/drivers/net/wireless/rt2x00/rt2x00mac.c | |||
| @@ -277,7 +277,6 @@ int rt2x00mac_add_interface(struct ieee80211_hw *hw, | |||
| 277 | else | 277 | else |
| 278 | rt2x00dev->intf_sta_count++; | 278 | rt2x00dev->intf_sta_count++; |
| 279 | 279 | ||
| 280 | spin_lock_init(&intf->seqlock); | ||
| 281 | mutex_init(&intf->beacon_skb_mutex); | 280 | mutex_init(&intf->beacon_skb_mutex); |
| 282 | intf->beacon = entry; | 281 | intf->beacon = entry; |
| 283 | 282 | ||
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c index 4c662eccf53c..2fd830103415 100644 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c | |||
| @@ -207,6 +207,7 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev, | |||
| 207 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); | 207 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); |
| 208 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | 208 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
| 209 | struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif); | 209 | struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif); |
| 210 | u16 seqno; | ||
| 210 | 211 | ||
| 211 | if (!(tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ)) | 212 | if (!(tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ)) |
| 212 | return; | 213 | return; |
| @@ -238,15 +239,13 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev, | |||
| 238 | * sequence counting per-frame, since those will override the | 239 | * sequence counting per-frame, since those will override the |
| 239 | * sequence counter given by mac80211. | 240 | * sequence counter given by mac80211. |
| 240 | */ | 241 | */ |
| 241 | spin_lock(&intf->seqlock); | ||
| 242 | |||
| 243 | if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags)) | 242 | if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags)) |
| 244 | intf->seqno += 0x10; | 243 | seqno = atomic_add_return(0x10, &intf->seqno); |
| 245 | hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG); | 244 | else |
| 246 | hdr->seq_ctrl |= cpu_to_le16(intf->seqno); | 245 | seqno = atomic_read(&intf->seqno); |
| 247 | |||
| 248 | spin_unlock(&intf->seqlock); | ||
| 249 | 246 | ||
| 247 | hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG); | ||
| 248 | hdr->seq_ctrl |= cpu_to_le16(seqno); | ||
| 250 | } | 249 | } |
| 251 | 250 | ||
| 252 | static void rt2x00queue_create_tx_descriptor_plcp(struct rt2x00_dev *rt2x00dev, | 251 | static void rt2x00queue_create_tx_descriptor_plcp(struct rt2x00_dev *rt2x00dev, |
diff --git a/drivers/net/wireless/rtl818x/rtl8187/leds.c b/drivers/net/wireless/rtl818x/rtl8187/leds.c index 2e0de2f5f0f9..c2d5b495c179 100644 --- a/drivers/net/wireless/rtl818x/rtl8187/leds.c +++ b/drivers/net/wireless/rtl818x/rtl8187/leds.c | |||
| @@ -117,7 +117,7 @@ static void rtl8187_led_brightness_set(struct led_classdev *led_dev, | |||
| 117 | radio_on = true; | 117 | radio_on = true; |
| 118 | } else if (radio_on) { | 118 | } else if (radio_on) { |
| 119 | radio_on = false; | 119 | radio_on = false; |
| 120 | cancel_delayed_work_sync(&priv->led_on); | 120 | cancel_delayed_work(&priv->led_on); |
| 121 | ieee80211_queue_delayed_work(hw, &priv->led_off, 0); | 121 | ieee80211_queue_delayed_work(hw, &priv->led_off, 0); |
| 122 | } | 122 | } |
| 123 | } else if (radio_on) { | 123 | } else if (radio_on) { |
