aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-09-17 23:53:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-17 23:53:52 -0400
commitf205ce83a766c08965ec78342f138cdc00631fba (patch)
tree7a9d2db6c16594ef7c730ca93a87131cf0abca41
parent3dc95666df0e1ae5b7381a8ec97a583bb3ce4306 (diff)
parentb31c50a7f9e93a61d14740dedcbbf2c376998bc7 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (66 commits) be2net: fix some cmds to use mccq instead of mbox atl1e: fix 2.6.31-git4 -- ATL1E 0000:03:00.0: DMA-API: device driver frees DMA pkt_sched: Fix qstats.qlen updating in dump_stats ipv6: Log the affected address when DAD failure occurs wl12xx: Fix print_mac() conversion. af_iucv: fix race when queueing skbs on the backlog queue af_iucv: do not call iucv_sock_kill() twice af_iucv: handle non-accepted sockets after resuming from suspend af_iucv: fix race in __iucv_sock_wait() iucv: use correct output register in iucv_query_maxconn() iucv: fix iucv_buffer_cpumask check when calling IUCV functions iucv: suspend/resume error msg for left over pathes wl12xx: switch to %pM to print the mac address b44: the poll handler b44_poll must not enable IRQ unconditionally ipv6: Ignore route option with ROUTER_PREF_INVALID bonding: make ab_arp select active slaves as other modes cfg80211: fix SME connect rc80211_minstrel: fix contention window calculation ssb/sdio: fix printk format warnings p54usb: add Zcomax XG-705A usbid ...
-rw-r--r--drivers/net/atl1e/atl1e.h9
-rw-r--r--drivers/net/atl1e/atl1e_main.c15
-rw-r--r--drivers/net/b44.c7
-rw-r--r--drivers/net/benet/be.h1
-rw-r--r--drivers/net/benet/be_cmds.c412
-rw-r--r--drivers/net/benet/be_cmds.h5
-rw-r--r--drivers/net/benet/be_main.c42
-rw-r--r--drivers/net/bonding/bond_main.c131
-rw-r--r--drivers/net/can/vcan.c2
-rw-r--r--drivers/net/igb/e1000_82575.c198
-rw-r--r--drivers/net/igb/e1000_82575.h2
-rw-r--r--drivers/net/igb/e1000_defines.h2
-rw-r--r--drivers/net/igb/e1000_phy.c5
-rw-r--r--drivers/net/igb/igb_main.c2
-rw-r--r--drivers/net/ixgbe/ixgbe_82598.c6
-rw-r--r--drivers/net/ixgbe/ixgbe_82599.c3
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c4
-rw-r--r--drivers/net/ixgbe/ixgbe_type.h2
-rw-r--r--drivers/net/mlx4/catas.c11
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c10
-rw-r--r--drivers/net/pppol2tp.c4
-rw-r--r--drivers/net/sky2.c24
-rw-r--r--drivers/net/smc91x.h28
-rw-r--r--drivers/net/usb/cdc-phonet.c1
-rw-r--r--drivers/net/wireless/Kconfig1
-rw-r--r--drivers/net/wireless/ath/ath9k/ani.c6
-rw-r--r--drivers/net/wireless/b43/main.c8
-rw-r--r--drivers/net/wireless/hostap/hostap_main.c3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c10
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c24
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c24
-rw-r--r--drivers/net/wireless/p54/p54usb.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_main.c5
-rw-r--r--drivers/serial/serial_cs.c14
-rw-r--r--drivers/ssb/pci.c1
-rw-r--r--drivers/ssb/sdio.c6
-rw-r--r--firmware/Makefile3
-rw-r--r--firmware/WHENCE12
-rw-r--r--firmware/cis/MT5634ZLX.cis.ihex11
-rw-r--r--firmware/cis/PCMLM28.cis.ihex18
-rw-r--r--firmware/cis/RS-COM-2P.cis.ihex10
-rw-r--r--include/keys/rxrpc-type.h107
-rw-r--r--include/linux/igmp.h2
-rw-r--r--include/linux/net.h5
-rw-r--r--include/linux/netdevice.h3
-rw-r--r--include/linux/netlink.h4
-rw-r--r--include/linux/notifier.h2
-rw-r--r--include/linux/rxrpc.h7
-rw-r--r--include/net/addrconf.h2
-rw-r--r--include/net/protocol.h13
-rw-r--r--include/net/sch_generic.h2
-rw-r--r--include/net/tcp.h7
-rw-r--r--net/appletalk/ddp.c2
-rw-r--r--net/can/af_can.c4
-rw-r--r--net/core/dev.c4
-rw-r--r--net/dccp/ccids/Kconfig6
-rw-r--r--net/dccp/ccids/ccid2.c2
-rw-r--r--net/dccp/ccids/ccid2.h8
-rw-r--r--net/dccp/ccids/ccid3.c5
-rw-r--r--net/dccp/ccids/ccid3.h50
-rw-r--r--net/dccp/ccids/lib/loss_interval.c7
-rw-r--r--net/dccp/ccids/lib/loss_interval.h2
-rw-r--r--net/dccp/ccids/lib/packet_history.c4
-rw-r--r--net/dccp/ccids/lib/packet_history.h1
-rw-r--r--net/dccp/ccids/lib/tfrc.h4
-rw-r--r--net/dccp/ccids/lib/tfrc_equation.c26
-rw-r--r--net/dccp/ipv4.c2
-rw-r--r--net/dccp/ipv6.c4
-rw-r--r--net/ieee802154/dgram.c2
-rw-r--r--net/ieee802154/netlink.c4
-rw-r--r--net/ieee802154/raw.c2
-rw-r--r--net/ipv4/af_inet.c18
-rw-r--r--net/ipv4/ah4.c2
-rw-r--r--net/ipv4/devinet.c6
-rw-r--r--net/ipv4/esp4.c2
-rw-r--r--net/ipv4/icmp.c2
-rw-r--r--net/ipv4/igmp.c22
-rw-r--r--net/ipv4/ip_gre.c2
-rw-r--r--net/ipv4/ip_input.c2
-rw-r--r--net/ipv4/ipcomp.c2
-rw-r--r--net/ipv4/ipmr.c6
-rw-r--r--net/ipv4/protocol.c6
-rw-r--r--net/ipv4/tcp.c2
-rw-r--r--net/ipv4/tcp_input.c2
-rw-r--r--net/ipv4/tcp_ipv4.c4
-rw-r--r--net/ipv4/tcp_minisocks.c4
-rw-r--r--net/ipv4/tunnel4.c4
-rw-r--r--net/ipv4/udplite.c2
-rw-r--r--net/ipv6/addrconf.c23
-rw-r--r--net/ipv6/af_inet6.c10
-rw-r--r--net/ipv6/ah6.c2
-rw-r--r--net/ipv6/esp6.c2
-rw-r--r--net/ipv6/exthdrs.c6
-rw-r--r--net/ipv6/icmp.c4
-rw-r--r--net/ipv6/ip6_input.c2
-rw-r--r--net/ipv6/ip6mr.c6
-rw-r--r--net/ipv6/ipcomp6.c2
-rw-r--r--net/ipv6/mcast.c19
-rw-r--r--net/ipv6/protocol.c6
-rw-r--r--net/ipv6/reassembly.c2
-rw-r--r--net/ipv6/route.c2
-rw-r--r--net/ipv6/tcp_ipv6.c7
-rw-r--r--net/ipv6/tunnel6.c4
-rw-r--r--net/ipv6/udp.c2
-rw-r--r--net/ipv6/udplite.c2
-rw-r--r--net/iucv/af_iucv.c33
-rw-r--r--net/iucv/iucv.c38
-rw-r--r--net/mac80211/rc80211_minstrel.c2
-rw-r--r--net/netlink/af_netlink.c51
-rw-r--r--net/netlink/genetlink.c5
-rw-r--r--net/phonet/pn_dev.c9
-rw-r--r--net/rds/af_rds.c2
-rw-r--r--net/rose/af_rose.c4
-rw-r--r--net/rxrpc/ar-ack.c6
-rw-r--r--net/rxrpc/ar-internal.h32
-rw-r--r--net/rxrpc/ar-key.c914
-rw-r--r--net/rxrpc/ar-security.c8
-rw-r--r--net/rxrpc/rxkad.c47
-rw-r--r--net/sched/sch_api.c29
-rw-r--r--net/sched/sch_drr.c4
-rw-r--r--net/sched/sch_mq.c14
-rw-r--r--net/sched/sch_multiq.c1
-rw-r--r--net/sched/sch_prio.c1
-rw-r--r--net/sctp/ipv6.c2
-rw-r--r--net/sctp/protocol.c2
-rw-r--r--net/socket.c1
-rw-r--r--net/wireless/scan.c7
-rw-r--r--net/wireless/sme.c21
132 files changed, 2009 insertions, 805 deletions
diff --git a/drivers/net/atl1e/atl1e.h b/drivers/net/atl1e/atl1e.h
index ba48220df16a..490d3b38e0cb 100644
--- a/drivers/net/atl1e/atl1e.h
+++ b/drivers/net/atl1e/atl1e.h
@@ -377,10 +377,19 @@ struct atl1e_hw {
377 */ 377 */
378struct atl1e_tx_buffer { 378struct atl1e_tx_buffer {
379 struct sk_buff *skb; 379 struct sk_buff *skb;
380 u16 flags;
381#define ATL1E_TX_PCIMAP_SINGLE 0x0001
382#define ATL1E_TX_PCIMAP_PAGE 0x0002
383#define ATL1E_TX_PCIMAP_TYPE_MASK 0x0003
380 u16 length; 384 u16 length;
381 dma_addr_t dma; 385 dma_addr_t dma;
382}; 386};
383 387
388#define ATL1E_SET_PCIMAP_TYPE(tx_buff, type) do { \
389 ((tx_buff)->flags) &= ~ATL1E_TX_PCIMAP_TYPE_MASK; \
390 ((tx_buff)->flags) |= (type); \
391 } while (0)
392
384struct atl1e_rx_page { 393struct atl1e_rx_page {
385 dma_addr_t dma; /* receive rage DMA address */ 394 dma_addr_t dma; /* receive rage DMA address */
386 u8 *addr; /* receive rage virtual address */ 395 u8 *addr; /* receive rage virtual address */
diff --git a/drivers/net/atl1e/atl1e_main.c b/drivers/net/atl1e/atl1e_main.c
index 69b830f4b68f..955da733c2ad 100644
--- a/drivers/net/atl1e/atl1e_main.c
+++ b/drivers/net/atl1e/atl1e_main.c
@@ -635,7 +635,11 @@ static void atl1e_clean_tx_ring(struct atl1e_adapter *adapter)
635 for (index = 0; index < ring_count; index++) { 635 for (index = 0; index < ring_count; index++) {
636 tx_buffer = &tx_ring->tx_buffer[index]; 636 tx_buffer = &tx_ring->tx_buffer[index];
637 if (tx_buffer->dma) { 637 if (tx_buffer->dma) {
638 pci_unmap_page(pdev, tx_buffer->dma, 638 if (tx_buffer->flags & ATL1E_TX_PCIMAP_SINGLE)
639 pci_unmap_single(pdev, tx_buffer->dma,
640 tx_buffer->length, PCI_DMA_TODEVICE);
641 else if (tx_buffer->flags & ATL1E_TX_PCIMAP_PAGE)
642 pci_unmap_page(pdev, tx_buffer->dma,
639 tx_buffer->length, PCI_DMA_TODEVICE); 643 tx_buffer->length, PCI_DMA_TODEVICE);
640 tx_buffer->dma = 0; 644 tx_buffer->dma = 0;
641 } 645 }
@@ -1220,7 +1224,11 @@ static bool atl1e_clean_tx_irq(struct atl1e_adapter *adapter)
1220 while (next_to_clean != hw_next_to_clean) { 1224 while (next_to_clean != hw_next_to_clean) {
1221 tx_buffer = &tx_ring->tx_buffer[next_to_clean]; 1225 tx_buffer = &tx_ring->tx_buffer[next_to_clean];
1222 if (tx_buffer->dma) { 1226 if (tx_buffer->dma) {
1223 pci_unmap_page(adapter->pdev, tx_buffer->dma, 1227 if (tx_buffer->flags & ATL1E_TX_PCIMAP_SINGLE)
1228 pci_unmap_single(adapter->pdev, tx_buffer->dma,
1229 tx_buffer->length, PCI_DMA_TODEVICE);
1230 else if (tx_buffer->flags & ATL1E_TX_PCIMAP_PAGE)
1231 pci_unmap_page(adapter->pdev, tx_buffer->dma,
1224 tx_buffer->length, PCI_DMA_TODEVICE); 1232 tx_buffer->length, PCI_DMA_TODEVICE);
1225 tx_buffer->dma = 0; 1233 tx_buffer->dma = 0;
1226 } 1234 }
@@ -1741,6 +1749,7 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter,
1741 tx_buffer->length = map_len; 1749 tx_buffer->length = map_len;
1742 tx_buffer->dma = pci_map_single(adapter->pdev, 1750 tx_buffer->dma = pci_map_single(adapter->pdev,
1743 skb->data, hdr_len, PCI_DMA_TODEVICE); 1751 skb->data, hdr_len, PCI_DMA_TODEVICE);
1752 ATL1E_SET_PCIMAP_TYPE(tx_buffer, ATL1E_TX_PCIMAP_SINGLE);
1744 mapped_len += map_len; 1753 mapped_len += map_len;
1745 use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma); 1754 use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma);
1746 use_tpd->word2 = (use_tpd->word2 & (~TPD_BUFLEN_MASK)) | 1755 use_tpd->word2 = (use_tpd->word2 & (~TPD_BUFLEN_MASK)) |
@@ -1766,6 +1775,7 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter,
1766 tx_buffer->dma = 1775 tx_buffer->dma =
1767 pci_map_single(adapter->pdev, skb->data + mapped_len, 1776 pci_map_single(adapter->pdev, skb->data + mapped_len,
1768 map_len, PCI_DMA_TODEVICE); 1777 map_len, PCI_DMA_TODEVICE);
1778 ATL1E_SET_PCIMAP_TYPE(tx_buffer, ATL1E_TX_PCIMAP_SINGLE);
1769 mapped_len += map_len; 1779 mapped_len += map_len;
1770 use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma); 1780 use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma);
1771 use_tpd->word2 = (use_tpd->word2 & (~TPD_BUFLEN_MASK)) | 1781 use_tpd->word2 = (use_tpd->word2 & (~TPD_BUFLEN_MASK)) |
@@ -1801,6 +1811,7 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter,
1801 (i * MAX_TX_BUF_LEN), 1811 (i * MAX_TX_BUF_LEN),
1802 tx_buffer->length, 1812 tx_buffer->length,
1803 PCI_DMA_TODEVICE); 1813 PCI_DMA_TODEVICE);
1814 ATL1E_SET_PCIMAP_TYPE(tx_buffer, ATL1E_TX_PCIMAP_PAGE);
1804 use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma); 1815 use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma);
1805 use_tpd->word2 = (use_tpd->word2 & (~TPD_BUFLEN_MASK)) | 1816 use_tpd->word2 = (use_tpd->word2 & (~TPD_BUFLEN_MASK)) |
1806 ((cpu_to_le32(tx_buffer->length) & 1817 ((cpu_to_le32(tx_buffer->length) &
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index 0189dcd36f31..e046943ef29d 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -847,23 +847,22 @@ static int b44_poll(struct napi_struct *napi, int budget)
847{ 847{
848 struct b44 *bp = container_of(napi, struct b44, napi); 848 struct b44 *bp = container_of(napi, struct b44, napi);
849 int work_done; 849 int work_done;
850 unsigned long flags;
850 851
851 spin_lock_irq(&bp->lock); 852 spin_lock_irqsave(&bp->lock, flags);
852 853
853 if (bp->istat & (ISTAT_TX | ISTAT_TO)) { 854 if (bp->istat & (ISTAT_TX | ISTAT_TO)) {
854 /* spin_lock(&bp->tx_lock); */ 855 /* spin_lock(&bp->tx_lock); */
855 b44_tx(bp); 856 b44_tx(bp);
856 /* spin_unlock(&bp->tx_lock); */ 857 /* spin_unlock(&bp->tx_lock); */
857 } 858 }
858 spin_unlock_irq(&bp->lock); 859 spin_unlock_irqrestore(&bp->lock, flags);
859 860
860 work_done = 0; 861 work_done = 0;
861 if (bp->istat & ISTAT_RX) 862 if (bp->istat & ISTAT_RX)
862 work_done += b44_rx(bp, budget); 863 work_done += b44_rx(bp, budget);
863 864
864 if (bp->istat & ISTAT_ERRORS) { 865 if (bp->istat & ISTAT_ERRORS) {
865 unsigned long flags;
866
867 spin_lock_irqsave(&bp->lock, flags); 866 spin_lock_irqsave(&bp->lock, flags);
868 b44_halt(bp); 867 b44_halt(bp);
869 b44_init_rings(bp); 868 b44_init_rings(bp);
diff --git a/drivers/net/benet/be.h b/drivers/net/benet/be.h
index 13b72ce870de..684c6fe24c8d 100644
--- a/drivers/net/benet/be.h
+++ b/drivers/net/benet/be.h
@@ -362,5 +362,6 @@ static inline u8 is_udp_pkt(struct sk_buff *skb)
362extern void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm, 362extern void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm,
363 u16 num_popped); 363 u16 num_popped);
364extern void be_link_status_update(struct be_adapter *adapter, bool link_up); 364extern void be_link_status_update(struct be_adapter *adapter, bool link_up);
365extern void netdev_stats_update(struct be_adapter *adapter);
365extern int be_load_fw(struct be_adapter *adapter, u8 *func); 366extern int be_load_fw(struct be_adapter *adapter, u8 *func);
366#endif /* BE_H */ 367#endif /* BE_H */
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c
index 1db092498309..3dd76c4170bf 100644
--- a/drivers/net/benet/be_cmds.c
+++ b/drivers/net/benet/be_cmds.c
@@ -59,15 +59,22 @@ static int be_mcc_compl_process(struct be_adapter *adapter,
59 59
60 compl_status = (compl->status >> CQE_STATUS_COMPL_SHIFT) & 60 compl_status = (compl->status >> CQE_STATUS_COMPL_SHIFT) &
61 CQE_STATUS_COMPL_MASK; 61 CQE_STATUS_COMPL_MASK;
62 if (compl_status != MCC_STATUS_SUCCESS) { 62 if (compl_status == MCC_STATUS_SUCCESS) {
63 if (compl->tag0 == OPCODE_ETH_GET_STATISTICS) {
64 struct be_cmd_resp_get_stats *resp =
65 adapter->stats.cmd.va;
66 be_dws_le_to_cpu(&resp->hw_stats,
67 sizeof(resp->hw_stats));
68 netdev_stats_update(adapter);
69 }
70 } else if (compl_status != MCC_STATUS_NOT_SUPPORTED) {
63 extd_status = (compl->status >> CQE_STATUS_EXTD_SHIFT) & 71 extd_status = (compl->status >> CQE_STATUS_EXTD_SHIFT) &
64 CQE_STATUS_EXTD_MASK; 72 CQE_STATUS_EXTD_MASK;
65 dev_warn(&adapter->pdev->dev, 73 dev_warn(&adapter->pdev->dev,
66 "Error in cmd completion: status(compl/extd)=%d/%d\n", 74 "Error in cmd completion: status(compl/extd)=%d/%d\n",
67 compl_status, extd_status); 75 compl_status, extd_status);
68 return -1;
69 } 76 }
70 return 0; 77 return compl_status;
71} 78}
72 79
73/* Link state evt is a string of bytes; no need for endian swapping */ 80/* Link state evt is a string of bytes; no need for endian swapping */
@@ -97,10 +104,10 @@ static struct be_mcc_compl *be_mcc_compl_get(struct be_adapter *adapter)
97 return NULL; 104 return NULL;
98} 105}
99 106
100void be_process_mcc(struct be_adapter *adapter) 107int be_process_mcc(struct be_adapter *adapter)
101{ 108{
102 struct be_mcc_compl *compl; 109 struct be_mcc_compl *compl;
103 int num = 0; 110 int num = 0, status = 0;
104 111
105 spin_lock_bh(&adapter->mcc_cq_lock); 112 spin_lock_bh(&adapter->mcc_cq_lock);
106 while ((compl = be_mcc_compl_get(adapter))) { 113 while ((compl = be_mcc_compl_get(adapter))) {
@@ -111,38 +118,47 @@ void be_process_mcc(struct be_adapter *adapter)
111 /* Interpret compl as a async link evt */ 118 /* Interpret compl as a async link evt */
112 be_async_link_state_process(adapter, 119 be_async_link_state_process(adapter,
113 (struct be_async_event_link_state *) compl); 120 (struct be_async_event_link_state *) compl);
114 } else { 121 } else if (compl->flags & CQE_FLAGS_COMPLETED_MASK) {
115 be_mcc_compl_process(adapter, compl); 122 status = be_mcc_compl_process(adapter, compl);
116 atomic_dec(&adapter->mcc_obj.q.used); 123 atomic_dec(&adapter->mcc_obj.q.used);
117 } 124 }
118 be_mcc_compl_use(compl); 125 be_mcc_compl_use(compl);
119 num++; 126 num++;
120 } 127 }
128
121 if (num) 129 if (num)
122 be_cq_notify(adapter, adapter->mcc_obj.cq.id, true, num); 130 be_cq_notify(adapter, adapter->mcc_obj.cq.id, true, num);
131
123 spin_unlock_bh(&adapter->mcc_cq_lock); 132 spin_unlock_bh(&adapter->mcc_cq_lock);
133 return status;
124} 134}
125 135
126/* Wait till no more pending mcc requests are present */ 136/* Wait till no more pending mcc requests are present */
127static void be_mcc_wait_compl(struct be_adapter *adapter) 137static int be_mcc_wait_compl(struct be_adapter *adapter)
128{ 138{
129#define mcc_timeout 50000 /* 5s timeout */ 139#define mcc_timeout 120000 /* 12s timeout */
130 int i; 140 int i, status;
131 for (i = 0; i < mcc_timeout; i++) { 141 for (i = 0; i < mcc_timeout; i++) {
132 be_process_mcc(adapter); 142 status = be_process_mcc(adapter);
143 if (status)
144 return status;
145
133 if (atomic_read(&adapter->mcc_obj.q.used) == 0) 146 if (atomic_read(&adapter->mcc_obj.q.used) == 0)
134 break; 147 break;
135 udelay(100); 148 udelay(100);
136 } 149 }
137 if (i == mcc_timeout) 150 if (i == mcc_timeout) {
138 dev_err(&adapter->pdev->dev, "mccq poll timed out\n"); 151 dev_err(&adapter->pdev->dev, "mccq poll timed out\n");
152 return -1;
153 }
154 return 0;
139} 155}
140 156
141/* Notify MCC requests and wait for completion */ 157/* Notify MCC requests and wait for completion */
142static void be_mcc_notify_wait(struct be_adapter *adapter) 158static int be_mcc_notify_wait(struct be_adapter *adapter)
143{ 159{
144 be_mcc_notify(adapter); 160 be_mcc_notify(adapter);
145 be_mcc_wait_compl(adapter); 161 return be_mcc_wait_compl(adapter);
146} 162}
147 163
148static int be_mbox_db_ready_wait(struct be_adapter *adapter, void __iomem *db) 164static int be_mbox_db_ready_wait(struct be_adapter *adapter, void __iomem *db)
@@ -173,7 +189,7 @@ static int be_mbox_db_ready_wait(struct be_adapter *adapter, void __iomem *db)
173 * Insert the mailbox address into the doorbell in two steps 189 * Insert the mailbox address into the doorbell in two steps
174 * Polls on the mbox doorbell till a command completion (or a timeout) occurs 190 * Polls on the mbox doorbell till a command completion (or a timeout) occurs
175 */ 191 */
176static int be_mbox_notify(struct be_adapter *adapter) 192static int be_mbox_notify_wait(struct be_adapter *adapter)
177{ 193{
178 int status; 194 int status;
179 u32 val = 0; 195 u32 val = 0;
@@ -182,8 +198,6 @@ static int be_mbox_notify(struct be_adapter *adapter)
182 struct be_mcc_mailbox *mbox = mbox_mem->va; 198 struct be_mcc_mailbox *mbox = mbox_mem->va;
183 struct be_mcc_compl *compl = &mbox->compl; 199 struct be_mcc_compl *compl = &mbox->compl;
184 200
185 memset(compl, 0, sizeof(*compl));
186
187 val |= MPU_MAILBOX_DB_HI_MASK; 201 val |= MPU_MAILBOX_DB_HI_MASK;
188 /* at bits 2 - 31 place mbox dma addr msb bits 34 - 63 */ 202 /* at bits 2 - 31 place mbox dma addr msb bits 34 - 63 */
189 val |= (upper_32_bits(mbox_mem->dma) >> 2) << 2; 203 val |= (upper_32_bits(mbox_mem->dma) >> 2) << 2;
@@ -310,34 +324,40 @@ static u32 eq_delay_to_mult(u32 usec_delay)
310 return multiplier; 324 return multiplier;
311} 325}
312 326
313static inline struct be_mcc_wrb *wrb_from_mbox(struct be_dma_mem *mbox_mem) 327static inline struct be_mcc_wrb *wrb_from_mbox(struct be_adapter *adapter)
314{ 328{
315 return &((struct be_mcc_mailbox *)(mbox_mem->va))->wrb; 329 struct be_dma_mem *mbox_mem = &adapter->mbox_mem;
330 struct be_mcc_wrb *wrb
331 = &((struct be_mcc_mailbox *)(mbox_mem->va))->wrb;
332 memset(wrb, 0, sizeof(*wrb));
333 return wrb;
316} 334}
317 335
318static inline struct be_mcc_wrb *wrb_from_mcc(struct be_queue_info *mccq) 336static struct be_mcc_wrb *wrb_from_mccq(struct be_adapter *adapter)
319{ 337{
320 struct be_mcc_wrb *wrb = NULL; 338 struct be_queue_info *mccq = &adapter->mcc_obj.q;
321 if (atomic_read(&mccq->used) < mccq->len) { 339 struct be_mcc_wrb *wrb;
322 wrb = queue_head_node(mccq); 340
323 queue_head_inc(mccq); 341 BUG_ON(atomic_read(&mccq->used) >= mccq->len);
324 atomic_inc(&mccq->used); 342 wrb = queue_head_node(mccq);
325 memset(wrb, 0, sizeof(*wrb)); 343 queue_head_inc(mccq);
326 } 344 atomic_inc(&mccq->used);
345 memset(wrb, 0, sizeof(*wrb));
327 return wrb; 346 return wrb;
328} 347}
329 348
330int be_cmd_eq_create(struct be_adapter *adapter, 349int be_cmd_eq_create(struct be_adapter *adapter,
331 struct be_queue_info *eq, int eq_delay) 350 struct be_queue_info *eq, int eq_delay)
332{ 351{
333 struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); 352 struct be_mcc_wrb *wrb;
334 struct be_cmd_req_eq_create *req = embedded_payload(wrb); 353 struct be_cmd_req_eq_create *req;
335 struct be_cmd_resp_eq_create *resp = embedded_payload(wrb);
336 struct be_dma_mem *q_mem = &eq->dma_mem; 354 struct be_dma_mem *q_mem = &eq->dma_mem;
337 int status; 355 int status;
338 356
339 spin_lock(&adapter->mbox_lock); 357 spin_lock(&adapter->mbox_lock);
340 memset(wrb, 0, sizeof(*wrb)); 358
359 wrb = wrb_from_mbox(adapter);
360 req = embedded_payload(wrb);
341 361
342 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 362 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
343 363
@@ -359,25 +379,29 @@ int be_cmd_eq_create(struct be_adapter *adapter,
359 379
360 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); 380 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
361 381
362 status = be_mbox_notify(adapter); 382 status = be_mbox_notify_wait(adapter);
363 if (!status) { 383 if (!status) {
384 struct be_cmd_resp_eq_create *resp = embedded_payload(wrb);
364 eq->id = le16_to_cpu(resp->eq_id); 385 eq->id = le16_to_cpu(resp->eq_id);
365 eq->created = true; 386 eq->created = true;
366 } 387 }
388
367 spin_unlock(&adapter->mbox_lock); 389 spin_unlock(&adapter->mbox_lock);
368 return status; 390 return status;
369} 391}
370 392
393/* Uses mbox */
371int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr, 394int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr,
372 u8 type, bool permanent, u32 if_handle) 395 u8 type, bool permanent, u32 if_handle)
373{ 396{
374 struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); 397 struct be_mcc_wrb *wrb;
375 struct be_cmd_req_mac_query *req = embedded_payload(wrb); 398 struct be_cmd_req_mac_query *req;
376 struct be_cmd_resp_mac_query *resp = embedded_payload(wrb);
377 int status; 399 int status;
378 400
379 spin_lock(&adapter->mbox_lock); 401 spin_lock(&adapter->mbox_lock);
380 memset(wrb, 0, sizeof(*wrb)); 402
403 wrb = wrb_from_mbox(adapter);
404 req = embedded_payload(wrb);
381 405
382 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 406 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
383 407
@@ -388,27 +412,32 @@ int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr,
388 if (permanent) { 412 if (permanent) {
389 req->permanent = 1; 413 req->permanent = 1;
390 } else { 414 } else {
391 req->if_id = cpu_to_le16((u16)if_handle); 415 req->if_id = cpu_to_le16((u16) if_handle);
392 req->permanent = 0; 416 req->permanent = 0;
393 } 417 }
394 418
395 status = be_mbox_notify(adapter); 419 status = be_mbox_notify_wait(adapter);
396 if (!status) 420 if (!status) {
421 struct be_cmd_resp_mac_query *resp = embedded_payload(wrb);
397 memcpy(mac_addr, resp->mac.addr, ETH_ALEN); 422 memcpy(mac_addr, resp->mac.addr, ETH_ALEN);
423 }
398 424
399 spin_unlock(&adapter->mbox_lock); 425 spin_unlock(&adapter->mbox_lock);
400 return status; 426 return status;
401} 427}
402 428
429/* Uses synchronous MCCQ */
403int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr, 430int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr,
404 u32 if_id, u32 *pmac_id) 431 u32 if_id, u32 *pmac_id)
405{ 432{
406 struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); 433 struct be_mcc_wrb *wrb;
407 struct be_cmd_req_pmac_add *req = embedded_payload(wrb); 434 struct be_cmd_req_pmac_add *req;
408 int status; 435 int status;
409 436
410 spin_lock(&adapter->mbox_lock); 437 spin_lock_bh(&adapter->mcc_lock);
411 memset(wrb, 0, sizeof(*wrb)); 438
439 wrb = wrb_from_mccq(adapter);
440 req = embedded_payload(wrb);
412 441
413 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 442 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
414 443
@@ -418,24 +447,27 @@ int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr,
418 req->if_id = cpu_to_le32(if_id); 447 req->if_id = cpu_to_le32(if_id);
419 memcpy(req->mac_address, mac_addr, ETH_ALEN); 448 memcpy(req->mac_address, mac_addr, ETH_ALEN);
420 449
421 status = be_mbox_notify(adapter); 450 status = be_mcc_notify_wait(adapter);
422 if (!status) { 451 if (!status) {
423 struct be_cmd_resp_pmac_add *resp = embedded_payload(wrb); 452 struct be_cmd_resp_pmac_add *resp = embedded_payload(wrb);
424 *pmac_id = le32_to_cpu(resp->pmac_id); 453 *pmac_id = le32_to_cpu(resp->pmac_id);
425 } 454 }
426 455
427 spin_unlock(&adapter->mbox_lock); 456 spin_unlock_bh(&adapter->mcc_lock);
428 return status; 457 return status;
429} 458}
430 459
460/* Uses synchronous MCCQ */
431int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id) 461int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id)
432{ 462{
433 struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); 463 struct be_mcc_wrb *wrb;
434 struct be_cmd_req_pmac_del *req = embedded_payload(wrb); 464 struct be_cmd_req_pmac_del *req;
435 int status; 465 int status;
436 466
437 spin_lock(&adapter->mbox_lock); 467 spin_lock_bh(&adapter->mcc_lock);
438 memset(wrb, 0, sizeof(*wrb)); 468
469 wrb = wrb_from_mccq(adapter);
470 req = embedded_payload(wrb);
439 471
440 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 472 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
441 473
@@ -445,25 +477,29 @@ int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id)
445 req->if_id = cpu_to_le32(if_id); 477 req->if_id = cpu_to_le32(if_id);
446 req->pmac_id = cpu_to_le32(pmac_id); 478 req->pmac_id = cpu_to_le32(pmac_id);
447 479
448 status = be_mbox_notify(adapter); 480 status = be_mcc_notify_wait(adapter);
449 spin_unlock(&adapter->mbox_lock); 481
482 spin_unlock_bh(&adapter->mcc_lock);
450 483
451 return status; 484 return status;
452} 485}
453 486
487/* Uses Mbox */
454int be_cmd_cq_create(struct be_adapter *adapter, 488int be_cmd_cq_create(struct be_adapter *adapter,
455 struct be_queue_info *cq, struct be_queue_info *eq, 489 struct be_queue_info *cq, struct be_queue_info *eq,
456 bool sol_evts, bool no_delay, int coalesce_wm) 490 bool sol_evts, bool no_delay, int coalesce_wm)
457{ 491{
458 struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); 492 struct be_mcc_wrb *wrb;
459 struct be_cmd_req_cq_create *req = embedded_payload(wrb); 493 struct be_cmd_req_cq_create *req;
460 struct be_cmd_resp_cq_create *resp = embedded_payload(wrb);
461 struct be_dma_mem *q_mem = &cq->dma_mem; 494 struct be_dma_mem *q_mem = &cq->dma_mem;
462 void *ctxt = &req->context; 495 void *ctxt;
463 int status; 496 int status;
464 497
465 spin_lock(&adapter->mbox_lock); 498 spin_lock(&adapter->mbox_lock);
466 memset(wrb, 0, sizeof(*wrb)); 499
500 wrb = wrb_from_mbox(adapter);
501 req = embedded_payload(wrb);
502 ctxt = &req->context;
467 503
468 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 504 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
469 505
@@ -486,11 +522,13 @@ int be_cmd_cq_create(struct be_adapter *adapter,
486 522
487 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); 523 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
488 524
489 status = be_mbox_notify(adapter); 525 status = be_mbox_notify_wait(adapter);
490 if (!status) { 526 if (!status) {
527 struct be_cmd_resp_cq_create *resp = embedded_payload(wrb);
491 cq->id = le16_to_cpu(resp->cq_id); 528 cq->id = le16_to_cpu(resp->cq_id);
492 cq->created = true; 529 cq->created = true;
493 } 530 }
531
494 spin_unlock(&adapter->mbox_lock); 532 spin_unlock(&adapter->mbox_lock);
495 533
496 return status; 534 return status;
@@ -508,14 +546,17 @@ int be_cmd_mccq_create(struct be_adapter *adapter,
508 struct be_queue_info *mccq, 546 struct be_queue_info *mccq,
509 struct be_queue_info *cq) 547 struct be_queue_info *cq)
510{ 548{
511 struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); 549 struct be_mcc_wrb *wrb;
512 struct be_cmd_req_mcc_create *req = embedded_payload(wrb); 550 struct be_cmd_req_mcc_create *req;
513 struct be_dma_mem *q_mem = &mccq->dma_mem; 551 struct be_dma_mem *q_mem = &mccq->dma_mem;
514 void *ctxt = &req->context; 552 void *ctxt;
515 int status; 553 int status;
516 554
517 spin_lock(&adapter->mbox_lock); 555 spin_lock(&adapter->mbox_lock);
518 memset(wrb, 0, sizeof(*wrb)); 556
557 wrb = wrb_from_mbox(adapter);
558 req = embedded_payload(wrb);
559 ctxt = &req->context;
519 560
520 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 561 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
521 562
@@ -534,7 +575,7 @@ int be_cmd_mccq_create(struct be_adapter *adapter,
534 575
535 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); 576 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
536 577
537 status = be_mbox_notify(adapter); 578 status = be_mbox_notify_wait(adapter);
538 if (!status) { 579 if (!status) {
539 struct be_cmd_resp_mcc_create *resp = embedded_payload(wrb); 580 struct be_cmd_resp_mcc_create *resp = embedded_payload(wrb);
540 mccq->id = le16_to_cpu(resp->id); 581 mccq->id = le16_to_cpu(resp->id);
@@ -549,15 +590,17 @@ int be_cmd_txq_create(struct be_adapter *adapter,
549 struct be_queue_info *txq, 590 struct be_queue_info *txq,
550 struct be_queue_info *cq) 591 struct be_queue_info *cq)
551{ 592{
552 struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); 593 struct be_mcc_wrb *wrb;
553 struct be_cmd_req_eth_tx_create *req = embedded_payload(wrb); 594 struct be_cmd_req_eth_tx_create *req;
554 struct be_dma_mem *q_mem = &txq->dma_mem; 595 struct be_dma_mem *q_mem = &txq->dma_mem;
555 void *ctxt = &req->context; 596 void *ctxt;
556 int status; 597 int status;
557 u32 len_encoded;
558 598
559 spin_lock(&adapter->mbox_lock); 599 spin_lock(&adapter->mbox_lock);
560 memset(wrb, 0, sizeof(*wrb)); 600
601 wrb = wrb_from_mbox(adapter);
602 req = embedded_payload(wrb);
603 ctxt = &req->context;
561 604
562 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 605 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
563 606
@@ -568,10 +611,8 @@ int be_cmd_txq_create(struct be_adapter *adapter,
568 req->ulp_num = BE_ULP1_NUM; 611 req->ulp_num = BE_ULP1_NUM;
569 req->type = BE_ETH_TX_RING_TYPE_STANDARD; 612 req->type = BE_ETH_TX_RING_TYPE_STANDARD;
570 613
571 len_encoded = fls(txq->len); /* log2(len) + 1 */ 614 AMAP_SET_BITS(struct amap_tx_context, tx_ring_size, ctxt,
572 if (len_encoded == 16) 615 be_encoded_q_len(txq->len));
573 len_encoded = 0;
574 AMAP_SET_BITS(struct amap_tx_context, tx_ring_size, ctxt, len_encoded);
575 AMAP_SET_BITS(struct amap_tx_context, pci_func_id, ctxt, 616 AMAP_SET_BITS(struct amap_tx_context, pci_func_id, ctxt,
576 be_pci_func(adapter)); 617 be_pci_func(adapter));
577 AMAP_SET_BITS(struct amap_tx_context, ctx_valid, ctxt, 1); 618 AMAP_SET_BITS(struct amap_tx_context, ctx_valid, ctxt, 1);
@@ -581,28 +622,32 @@ int be_cmd_txq_create(struct be_adapter *adapter,
581 622
582 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); 623 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
583 624
584 status = be_mbox_notify(adapter); 625 status = be_mbox_notify_wait(adapter);
585 if (!status) { 626 if (!status) {
586 struct be_cmd_resp_eth_tx_create *resp = embedded_payload(wrb); 627 struct be_cmd_resp_eth_tx_create *resp = embedded_payload(wrb);
587 txq->id = le16_to_cpu(resp->cid); 628 txq->id = le16_to_cpu(resp->cid);
588 txq->created = true; 629 txq->created = true;
589 } 630 }
631
590 spin_unlock(&adapter->mbox_lock); 632 spin_unlock(&adapter->mbox_lock);
591 633
592 return status; 634 return status;
593} 635}
594 636
637/* Uses mbox */
595int be_cmd_rxq_create(struct be_adapter *adapter, 638int be_cmd_rxq_create(struct be_adapter *adapter,
596 struct be_queue_info *rxq, u16 cq_id, u16 frag_size, 639 struct be_queue_info *rxq, u16 cq_id, u16 frag_size,
597 u16 max_frame_size, u32 if_id, u32 rss) 640 u16 max_frame_size, u32 if_id, u32 rss)
598{ 641{
599 struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); 642 struct be_mcc_wrb *wrb;
600 struct be_cmd_req_eth_rx_create *req = embedded_payload(wrb); 643 struct be_cmd_req_eth_rx_create *req;
601 struct be_dma_mem *q_mem = &rxq->dma_mem; 644 struct be_dma_mem *q_mem = &rxq->dma_mem;
602 int status; 645 int status;
603 646
604 spin_lock(&adapter->mbox_lock); 647 spin_lock(&adapter->mbox_lock);
605 memset(wrb, 0, sizeof(*wrb)); 648
649 wrb = wrb_from_mbox(adapter);
650 req = embedded_payload(wrb);
606 651
607 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 652 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
608 653
@@ -617,29 +662,34 @@ int be_cmd_rxq_create(struct be_adapter *adapter,
617 req->max_frame_size = cpu_to_le16(max_frame_size); 662 req->max_frame_size = cpu_to_le16(max_frame_size);
618 req->rss_queue = cpu_to_le32(rss); 663 req->rss_queue = cpu_to_le32(rss);
619 664
620 status = be_mbox_notify(adapter); 665 status = be_mbox_notify_wait(adapter);
621 if (!status) { 666 if (!status) {
622 struct be_cmd_resp_eth_rx_create *resp = embedded_payload(wrb); 667 struct be_cmd_resp_eth_rx_create *resp = embedded_payload(wrb);
623 rxq->id = le16_to_cpu(resp->id); 668 rxq->id = le16_to_cpu(resp->id);
624 rxq->created = true; 669 rxq->created = true;
625 } 670 }
671
626 spin_unlock(&adapter->mbox_lock); 672 spin_unlock(&adapter->mbox_lock);
627 673
628 return status; 674 return status;
629} 675}
630 676
631/* Generic destroyer function for all types of queues */ 677/* Generic destroyer function for all types of queues
678 * Uses Mbox
679 */
632int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q, 680int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q,
633 int queue_type) 681 int queue_type)
634{ 682{
635 struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); 683 struct be_mcc_wrb *wrb;
636 struct be_cmd_req_q_destroy *req = embedded_payload(wrb); 684 struct be_cmd_req_q_destroy *req;
637 u8 subsys = 0, opcode = 0; 685 u8 subsys = 0, opcode = 0;
638 int status; 686 int status;
639 687
640 spin_lock(&adapter->mbox_lock); 688 spin_lock(&adapter->mbox_lock);
641 689
642 memset(wrb, 0, sizeof(*wrb)); 690 wrb = wrb_from_mbox(adapter);
691 req = embedded_payload(wrb);
692
643 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 693 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
644 694
645 switch (queue_type) { 695 switch (queue_type) {
@@ -669,23 +719,27 @@ int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q,
669 be_cmd_hdr_prepare(&req->hdr, subsys, opcode, sizeof(*req)); 719 be_cmd_hdr_prepare(&req->hdr, subsys, opcode, sizeof(*req));
670 req->id = cpu_to_le16(q->id); 720 req->id = cpu_to_le16(q->id);
671 721
672 status = be_mbox_notify(adapter); 722 status = be_mbox_notify_wait(adapter);
673 723
674 spin_unlock(&adapter->mbox_lock); 724 spin_unlock(&adapter->mbox_lock);
675 725
676 return status; 726 return status;
677} 727}
678 728
679/* Create an rx filtering policy configuration on an i/f */ 729/* Create an rx filtering policy configuration on an i/f
730 * Uses mbox
731 */
680int be_cmd_if_create(struct be_adapter *adapter, u32 flags, u8 *mac, 732int be_cmd_if_create(struct be_adapter *adapter, u32 flags, u8 *mac,
681 bool pmac_invalid, u32 *if_handle, u32 *pmac_id) 733 bool pmac_invalid, u32 *if_handle, u32 *pmac_id)
682{ 734{
683 struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); 735 struct be_mcc_wrb *wrb;
684 struct be_cmd_req_if_create *req = embedded_payload(wrb); 736 struct be_cmd_req_if_create *req;
685 int status; 737 int status;
686 738
687 spin_lock(&adapter->mbox_lock); 739 spin_lock(&adapter->mbox_lock);
688 memset(wrb, 0, sizeof(*wrb)); 740
741 wrb = wrb_from_mbox(adapter);
742 req = embedded_payload(wrb);
689 743
690 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 744 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
691 745
@@ -694,10 +748,11 @@ int be_cmd_if_create(struct be_adapter *adapter, u32 flags, u8 *mac,
694 748
695 req->capability_flags = cpu_to_le32(flags); 749 req->capability_flags = cpu_to_le32(flags);
696 req->enable_flags = cpu_to_le32(flags); 750 req->enable_flags = cpu_to_le32(flags);
751 req->pmac_invalid = pmac_invalid;
697 if (!pmac_invalid) 752 if (!pmac_invalid)
698 memcpy(req->mac_addr, mac, ETH_ALEN); 753 memcpy(req->mac_addr, mac, ETH_ALEN);
699 754
700 status = be_mbox_notify(adapter); 755 status = be_mbox_notify_wait(adapter);
701 if (!status) { 756 if (!status) {
702 struct be_cmd_resp_if_create *resp = embedded_payload(wrb); 757 struct be_cmd_resp_if_create *resp = embedded_payload(wrb);
703 *if_handle = le32_to_cpu(resp->interface_id); 758 *if_handle = le32_to_cpu(resp->interface_id);
@@ -709,14 +764,17 @@ int be_cmd_if_create(struct be_adapter *adapter, u32 flags, u8 *mac,
709 return status; 764 return status;
710} 765}
711 766
767/* Uses mbox */
712int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id) 768int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id)
713{ 769{
714 struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); 770 struct be_mcc_wrb *wrb;
715 struct be_cmd_req_if_destroy *req = embedded_payload(wrb); 771 struct be_cmd_req_if_destroy *req;
716 int status; 772 int status;
717 773
718 spin_lock(&adapter->mbox_lock); 774 spin_lock(&adapter->mbox_lock);
719 memset(wrb, 0, sizeof(*wrb)); 775
776 wrb = wrb_from_mbox(adapter);
777 req = embedded_payload(wrb);
720 778
721 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 779 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
722 780
@@ -724,7 +782,8 @@ int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id)
724 OPCODE_COMMON_NTWK_INTERFACE_DESTROY, sizeof(*req)); 782 OPCODE_COMMON_NTWK_INTERFACE_DESTROY, sizeof(*req));
725 783
726 req->interface_id = cpu_to_le32(interface_id); 784 req->interface_id = cpu_to_le32(interface_id);
727 status = be_mbox_notify(adapter); 785
786 status = be_mbox_notify_wait(adapter);
728 787
729 spin_unlock(&adapter->mbox_lock); 788 spin_unlock(&adapter->mbox_lock);
730 789
@@ -733,20 +792,22 @@ int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id)
733 792
734/* Get stats is a non embedded command: the request is not embedded inside 793/* Get stats is a non embedded command: the request is not embedded inside
735 * WRB but is a separate dma memory block 794 * WRB but is a separate dma memory block
795 * Uses asynchronous MCC
736 */ 796 */
737int be_cmd_get_stats(struct be_adapter *adapter, struct be_dma_mem *nonemb_cmd) 797int be_cmd_get_stats(struct be_adapter *adapter, struct be_dma_mem *nonemb_cmd)
738{ 798{
739 struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); 799 struct be_mcc_wrb *wrb;
740 struct be_cmd_req_get_stats *req = nonemb_cmd->va; 800 struct be_cmd_req_get_stats *req;
741 struct be_sge *sge = nonembedded_sgl(wrb); 801 struct be_sge *sge;
742 int status;
743 802
744 spin_lock(&adapter->mbox_lock); 803 spin_lock_bh(&adapter->mcc_lock);
745 memset(wrb, 0, sizeof(*wrb));
746 804
747 memset(req, 0, sizeof(*req)); 805 wrb = wrb_from_mccq(adapter);
806 req = nonemb_cmd->va;
807 sge = nonembedded_sgl(wrb);
748 808
749 be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1); 809 be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1);
810 wrb->tag0 = OPCODE_ETH_GET_STATISTICS;
750 811
751 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, 812 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH,
752 OPCODE_ETH_GET_STATISTICS, sizeof(*req)); 813 OPCODE_ETH_GET_STATISTICS, sizeof(*req));
@@ -754,59 +815,61 @@ int be_cmd_get_stats(struct be_adapter *adapter, struct be_dma_mem *nonemb_cmd)
754 sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF); 815 sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF);
755 sge->len = cpu_to_le32(nonemb_cmd->size); 816 sge->len = cpu_to_le32(nonemb_cmd->size);
756 817
757 status = be_mbox_notify(adapter); 818 be_mcc_notify(adapter);
758 if (!status) {
759 struct be_cmd_resp_get_stats *resp = nonemb_cmd->va;
760 be_dws_le_to_cpu(&resp->hw_stats, sizeof(resp->hw_stats));
761 }
762 819
763 spin_unlock(&adapter->mbox_lock); 820 spin_unlock_bh(&adapter->mcc_lock);
764 return status; 821 return 0;
765} 822}
766 823
824/* Uses synchronous mcc */
767int be_cmd_link_status_query(struct be_adapter *adapter, 825int be_cmd_link_status_query(struct be_adapter *adapter,
768 bool *link_up) 826 bool *link_up)
769{ 827{
770 struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); 828 struct be_mcc_wrb *wrb;
771 struct be_cmd_req_link_status *req = embedded_payload(wrb); 829 struct be_cmd_req_link_status *req;
772 int status; 830 int status;
773 831
774 spin_lock(&adapter->mbox_lock); 832 spin_lock_bh(&adapter->mcc_lock);
833
834 wrb = wrb_from_mccq(adapter);
835 req = embedded_payload(wrb);
775 836
776 *link_up = false; 837 *link_up = false;
777 memset(wrb, 0, sizeof(*wrb));
778 838
779 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 839 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
780 840
781 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, 841 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
782 OPCODE_COMMON_NTWK_LINK_STATUS_QUERY, sizeof(*req)); 842 OPCODE_COMMON_NTWK_LINK_STATUS_QUERY, sizeof(*req));
783 843
784 status = be_mbox_notify(adapter); 844 status = be_mcc_notify_wait(adapter);
785 if (!status) { 845 if (!status) {
786 struct be_cmd_resp_link_status *resp = embedded_payload(wrb); 846 struct be_cmd_resp_link_status *resp = embedded_payload(wrb);
787 if (resp->mac_speed != PHY_LINK_SPEED_ZERO) 847 if (resp->mac_speed != PHY_LINK_SPEED_ZERO)
788 *link_up = true; 848 *link_up = true;
789 } 849 }
790 850
791 spin_unlock(&adapter->mbox_lock); 851 spin_unlock_bh(&adapter->mcc_lock);
792 return status; 852 return status;
793} 853}
794 854
855/* Uses Mbox */
795int be_cmd_get_fw_ver(struct be_adapter *adapter, char *fw_ver) 856int be_cmd_get_fw_ver(struct be_adapter *adapter, char *fw_ver)
796{ 857{
797 struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); 858 struct be_mcc_wrb *wrb;
798 struct be_cmd_req_get_fw_version *req = embedded_payload(wrb); 859 struct be_cmd_req_get_fw_version *req;
799 int status; 860 int status;
800 861
801 spin_lock(&adapter->mbox_lock); 862 spin_lock(&adapter->mbox_lock);
802 memset(wrb, 0, sizeof(*wrb)); 863
864 wrb = wrb_from_mbox(adapter);
865 req = embedded_payload(wrb);
803 866
804 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 867 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
805 868
806 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, 869 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
807 OPCODE_COMMON_GET_FW_VERSION, sizeof(*req)); 870 OPCODE_COMMON_GET_FW_VERSION, sizeof(*req));
808 871
809 status = be_mbox_notify(adapter); 872 status = be_mbox_notify_wait(adapter);
810 if (!status) { 873 if (!status) {
811 struct be_cmd_resp_get_fw_version *resp = embedded_payload(wrb); 874 struct be_cmd_resp_get_fw_version *resp = embedded_payload(wrb);
812 strncpy(fw_ver, resp->firmware_version_string, FW_VER_LEN); 875 strncpy(fw_ver, resp->firmware_version_string, FW_VER_LEN);
@@ -816,15 +879,18 @@ int be_cmd_get_fw_ver(struct be_adapter *adapter, char *fw_ver)
816 return status; 879 return status;
817} 880}
818 881
819/* set the EQ delay interval of an EQ to specified value */ 882/* set the EQ delay interval of an EQ to specified value
883 * Uses async mcc
884 */
820int be_cmd_modify_eqd(struct be_adapter *adapter, u32 eq_id, u32 eqd) 885int be_cmd_modify_eqd(struct be_adapter *adapter, u32 eq_id, u32 eqd)
821{ 886{
822 struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); 887 struct be_mcc_wrb *wrb;
823 struct be_cmd_req_modify_eq_delay *req = embedded_payload(wrb); 888 struct be_cmd_req_modify_eq_delay *req;
824 int status;
825 889
826 spin_lock(&adapter->mbox_lock); 890 spin_lock_bh(&adapter->mcc_lock);
827 memset(wrb, 0, sizeof(*wrb)); 891
892 wrb = wrb_from_mccq(adapter);
893 req = embedded_payload(wrb);
828 894
829 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 895 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
830 896
@@ -836,21 +902,24 @@ int be_cmd_modify_eqd(struct be_adapter *adapter, u32 eq_id, u32 eqd)
836 req->delay[0].phase = 0; 902 req->delay[0].phase = 0;
837 req->delay[0].delay_multiplier = cpu_to_le32(eqd); 903 req->delay[0].delay_multiplier = cpu_to_le32(eqd);
838 904
839 status = be_mbox_notify(adapter); 905 be_mcc_notify(adapter);
840 906
841 spin_unlock(&adapter->mbox_lock); 907 spin_unlock_bh(&adapter->mcc_lock);
842 return status; 908 return 0;
843} 909}
844 910
911/* Uses sycnhronous mcc */
845int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array, 912int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array,
846 u32 num, bool untagged, bool promiscuous) 913 u32 num, bool untagged, bool promiscuous)
847{ 914{
848 struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); 915 struct be_mcc_wrb *wrb;
849 struct be_cmd_req_vlan_config *req = embedded_payload(wrb); 916 struct be_cmd_req_vlan_config *req;
850 int status; 917 int status;
851 918
852 spin_lock(&adapter->mbox_lock); 919 spin_lock_bh(&adapter->mcc_lock);
853 memset(wrb, 0, sizeof(*wrb)); 920
921 wrb = wrb_from_mccq(adapter);
922 req = embedded_payload(wrb);
854 923
855 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 924 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
856 925
@@ -866,23 +935,24 @@ int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array,
866 req->num_vlan * sizeof(vtag_array[0])); 935 req->num_vlan * sizeof(vtag_array[0]));
867 } 936 }
868 937
869 status = be_mbox_notify(adapter); 938 status = be_mcc_notify_wait(adapter);
870 939
871 spin_unlock(&adapter->mbox_lock); 940 spin_unlock_bh(&adapter->mcc_lock);
872 return status; 941 return status;
873} 942}
874 943
875/* Use MCC for this command as it may be called in BH context */ 944/* Uses MCC for this command as it may be called in BH context
945 * Uses synchronous mcc
946 */
876int be_cmd_promiscuous_config(struct be_adapter *adapter, u8 port_num, bool en) 947int be_cmd_promiscuous_config(struct be_adapter *adapter, u8 port_num, bool en)
877{ 948{
878 struct be_mcc_wrb *wrb; 949 struct be_mcc_wrb *wrb;
879 struct be_cmd_req_promiscuous_config *req; 950 struct be_cmd_req_promiscuous_config *req;
951 int status;
880 952
881 spin_lock_bh(&adapter->mcc_lock); 953 spin_lock_bh(&adapter->mcc_lock);
882 954
883 wrb = wrb_from_mcc(&adapter->mcc_obj.q); 955 wrb = wrb_from_mccq(adapter);
884 BUG_ON(!wrb);
885
886 req = embedded_payload(wrb); 956 req = embedded_payload(wrb);
887 957
888 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 958 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
@@ -895,14 +965,14 @@ int be_cmd_promiscuous_config(struct be_adapter *adapter, u8 port_num, bool en)
895 else 965 else
896 req->port0_promiscuous = en; 966 req->port0_promiscuous = en;
897 967
898 be_mcc_notify_wait(adapter); 968 status = be_mcc_notify_wait(adapter);
899 969
900 spin_unlock_bh(&adapter->mcc_lock); 970 spin_unlock_bh(&adapter->mcc_lock);
901 return 0; 971 return status;
902} 972}
903 973
904/* 974/*
905 * Use MCC for this command as it may be called in BH context 975 * Uses MCC for this command as it may be called in BH context
906 * (mc == NULL) => multicast promiscous 976 * (mc == NULL) => multicast promiscous
907 */ 977 */
908int be_cmd_multicast_set(struct be_adapter *adapter, u32 if_id, 978int be_cmd_multicast_set(struct be_adapter *adapter, u32 if_id,
@@ -914,9 +984,7 @@ int be_cmd_multicast_set(struct be_adapter *adapter, u32 if_id,
914 984
915 spin_lock_bh(&adapter->mcc_lock); 985 spin_lock_bh(&adapter->mcc_lock);
916 986
917 wrb = wrb_from_mcc(&adapter->mcc_obj.q); 987 wrb = wrb_from_mccq(adapter);
918 BUG_ON(!wrb);
919
920 req = embedded_payload(wrb); 988 req = embedded_payload(wrb);
921 989
922 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 990 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
@@ -944,15 +1012,17 @@ int be_cmd_multicast_set(struct be_adapter *adapter, u32 if_id,
944 return 0; 1012 return 0;
945} 1013}
946 1014
1015/* Uses synchrounous mcc */
947int be_cmd_set_flow_control(struct be_adapter *adapter, u32 tx_fc, u32 rx_fc) 1016int be_cmd_set_flow_control(struct be_adapter *adapter, u32 tx_fc, u32 rx_fc)
948{ 1017{
949 struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); 1018 struct be_mcc_wrb *wrb;
950 struct be_cmd_req_set_flow_control *req = embedded_payload(wrb); 1019 struct be_cmd_req_set_flow_control *req;
951 int status; 1020 int status;
952 1021
953 spin_lock(&adapter->mbox_lock); 1022 spin_lock_bh(&adapter->mcc_lock);
954 1023
955 memset(wrb, 0, sizeof(*wrb)); 1024 wrb = wrb_from_mccq(adapter);
1025 req = embedded_payload(wrb);
956 1026
957 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 1027 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
958 1028
@@ -962,28 +1032,30 @@ int be_cmd_set_flow_control(struct be_adapter *adapter, u32 tx_fc, u32 rx_fc)
962 req->tx_flow_control = cpu_to_le16((u16)tx_fc); 1032 req->tx_flow_control = cpu_to_le16((u16)tx_fc);
963 req->rx_flow_control = cpu_to_le16((u16)rx_fc); 1033 req->rx_flow_control = cpu_to_le16((u16)rx_fc);
964 1034
965 status = be_mbox_notify(adapter); 1035 status = be_mcc_notify_wait(adapter);
966 1036
967 spin_unlock(&adapter->mbox_lock); 1037 spin_unlock_bh(&adapter->mcc_lock);
968 return status; 1038 return status;
969} 1039}
970 1040
1041/* Uses sycn mcc */
971int be_cmd_get_flow_control(struct be_adapter *adapter, u32 *tx_fc, u32 *rx_fc) 1042int be_cmd_get_flow_control(struct be_adapter *adapter, u32 *tx_fc, u32 *rx_fc)
972{ 1043{
973 struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); 1044 struct be_mcc_wrb *wrb;
974 struct be_cmd_req_get_flow_control *req = embedded_payload(wrb); 1045 struct be_cmd_req_get_flow_control *req;
975 int status; 1046 int status;
976 1047
977 spin_lock(&adapter->mbox_lock); 1048 spin_lock_bh(&adapter->mcc_lock);
978 1049
979 memset(wrb, 0, sizeof(*wrb)); 1050 wrb = wrb_from_mccq(adapter);
1051 req = embedded_payload(wrb);
980 1052
981 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 1053 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
982 1054
983 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, 1055 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
984 OPCODE_COMMON_GET_FLOW_CONTROL, sizeof(*req)); 1056 OPCODE_COMMON_GET_FLOW_CONTROL, sizeof(*req));
985 1057
986 status = be_mbox_notify(adapter); 1058 status = be_mcc_notify_wait(adapter);
987 if (!status) { 1059 if (!status) {
988 struct be_cmd_resp_get_flow_control *resp = 1060 struct be_cmd_resp_get_flow_control *resp =
989 embedded_payload(wrb); 1061 embedded_payload(wrb);
@@ -991,26 +1063,28 @@ int be_cmd_get_flow_control(struct be_adapter *adapter, u32 *tx_fc, u32 *rx_fc)
991 *rx_fc = le16_to_cpu(resp->rx_flow_control); 1063 *rx_fc = le16_to_cpu(resp->rx_flow_control);
992 } 1064 }
993 1065
994 spin_unlock(&adapter->mbox_lock); 1066 spin_unlock_bh(&adapter->mcc_lock);
995 return status; 1067 return status;
996} 1068}
997 1069
1070/* Uses mbox */
998int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num) 1071int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num)
999{ 1072{
1000 struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); 1073 struct be_mcc_wrb *wrb;
1001 struct be_cmd_req_query_fw_cfg *req = embedded_payload(wrb); 1074 struct be_cmd_req_query_fw_cfg *req;
1002 int status; 1075 int status;
1003 1076
1004 spin_lock(&adapter->mbox_lock); 1077 spin_lock(&adapter->mbox_lock);
1005 1078
1006 memset(wrb, 0, sizeof(*wrb)); 1079 wrb = wrb_from_mbox(adapter);
1080 req = embedded_payload(wrb);
1007 1081
1008 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 1082 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
1009 1083
1010 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, 1084 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
1011 OPCODE_COMMON_QUERY_FIRMWARE_CONFIG, sizeof(*req)); 1085 OPCODE_COMMON_QUERY_FIRMWARE_CONFIG, sizeof(*req));
1012 1086
1013 status = be_mbox_notify(adapter); 1087 status = be_mbox_notify_wait(adapter);
1014 if (!status) { 1088 if (!status) {
1015 struct be_cmd_resp_query_fw_cfg *resp = embedded_payload(wrb); 1089 struct be_cmd_resp_query_fw_cfg *resp = embedded_payload(wrb);
1016 *port_num = le32_to_cpu(resp->phys_port); 1090 *port_num = le32_to_cpu(resp->phys_port);
@@ -1020,22 +1094,24 @@ int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num)
1020 return status; 1094 return status;
1021} 1095}
1022 1096
1097/* Uses mbox */
1023int be_cmd_reset_function(struct be_adapter *adapter) 1098int be_cmd_reset_function(struct be_adapter *adapter)
1024{ 1099{
1025 struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); 1100 struct be_mcc_wrb *wrb;
1026 struct be_cmd_req_hdr *req = embedded_payload(wrb); 1101 struct be_cmd_req_hdr *req;
1027 int status; 1102 int status;
1028 1103
1029 spin_lock(&adapter->mbox_lock); 1104 spin_lock(&adapter->mbox_lock);
1030 1105
1031 memset(wrb, 0, sizeof(*wrb)); 1106 wrb = wrb_from_mbox(adapter);
1107 req = embedded_payload(wrb);
1032 1108
1033 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 1109 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
1034 1110
1035 be_cmd_hdr_prepare(req, CMD_SUBSYSTEM_COMMON, 1111 be_cmd_hdr_prepare(req, CMD_SUBSYSTEM_COMMON,
1036 OPCODE_COMMON_FUNCTION_RESET, sizeof(*req)); 1112 OPCODE_COMMON_FUNCTION_RESET, sizeof(*req));
1037 1113
1038 status = be_mbox_notify(adapter); 1114 status = be_mbox_notify_wait(adapter);
1039 1115
1040 spin_unlock(&adapter->mbox_lock); 1116 spin_unlock(&adapter->mbox_lock);
1041 return status; 1117 return status;
@@ -1044,13 +1120,17 @@ int be_cmd_reset_function(struct be_adapter *adapter)
1044int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd, 1120int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd,
1045 u32 flash_type, u32 flash_opcode, u32 buf_size) 1121 u32 flash_type, u32 flash_opcode, u32 buf_size)
1046{ 1122{
1047 struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); 1123 struct be_mcc_wrb *wrb;
1048 struct be_cmd_write_flashrom *req = cmd->va; 1124 struct be_cmd_write_flashrom *req = cmd->va;
1049 struct be_sge *sge = nonembedded_sgl(wrb); 1125 struct be_sge *sge;
1050 int status; 1126 int status;
1051 1127
1052 spin_lock(&adapter->mbox_lock); 1128 spin_lock_bh(&adapter->mcc_lock);
1053 memset(wrb, 0, sizeof(*wrb)); 1129
1130 wrb = wrb_from_mccq(adapter);
1131 req = embedded_payload(wrb);
1132 sge = nonembedded_sgl(wrb);
1133
1054 be_wrb_hdr_prepare(wrb, cmd->size, false, 1); 1134 be_wrb_hdr_prepare(wrb, cmd->size, false, 1);
1055 1135
1056 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, 1136 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
@@ -1063,8 +1143,8 @@ int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd,
1063 req->params.op_code = cpu_to_le32(flash_opcode); 1143 req->params.op_code = cpu_to_le32(flash_opcode);
1064 req->params.data_buf_size = cpu_to_le32(buf_size); 1144 req->params.data_buf_size = cpu_to_le32(buf_size);
1065 1145
1066 status = be_mbox_notify(adapter); 1146 status = be_mcc_notify_wait(adapter);
1067 1147
1068 spin_unlock(&adapter->mbox_lock); 1148 spin_unlock_bh(&adapter->mcc_lock);
1069 return status; 1149 return status;
1070} 1150}
diff --git a/drivers/net/benet/be_cmds.h b/drivers/net/benet/be_cmds.h
index fd7028e5b78e..93e432f3d926 100644
--- a/drivers/net/benet/be_cmds.h
+++ b/drivers/net/benet/be_cmds.h
@@ -61,7 +61,8 @@ enum {
61/* The command is completing because the queue was getting flushed */ 61/* The command is completing because the queue was getting flushed */
62 MCC_STATUS_QUEUE_FLUSHING = 0x4, 62 MCC_STATUS_QUEUE_FLUSHING = 0x4,
63/* The command is completing with a DMA error */ 63/* The command is completing with a DMA error */
64 MCC_STATUS_DMA_FAILED = 0x5 64 MCC_STATUS_DMA_FAILED = 0x5,
65 MCC_STATUS_NOT_SUPPORTED = 0x66
65}; 66};
66 67
67#define CQE_STATUS_COMPL_MASK 0xFFFF 68#define CQE_STATUS_COMPL_MASK 0xFFFF
@@ -761,7 +762,7 @@ extern int be_cmd_get_flow_control(struct be_adapter *adapter,
761 u32 *tx_fc, u32 *rx_fc); 762 u32 *tx_fc, u32 *rx_fc);
762extern int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num); 763extern int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num);
763extern int be_cmd_reset_function(struct be_adapter *adapter); 764extern int be_cmd_reset_function(struct be_adapter *adapter);
764extern void be_process_mcc(struct be_adapter *adapter); 765extern int be_process_mcc(struct be_adapter *adapter);
765extern int be_cmd_write_flashrom(struct be_adapter *adapter, 766extern int be_cmd_write_flashrom(struct be_adapter *adapter,
766 struct be_dma_mem *cmd, u32 flash_oper, 767 struct be_dma_mem *cmd, u32 flash_oper,
767 u32 flash_opcode, u32 buf_size); 768 u32 flash_opcode, u32 buf_size);
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
index ce11bba2cb67..409cf0595903 100644
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -135,7 +135,7 @@ static int be_mac_addr_set(struct net_device *netdev, void *p)
135 return status; 135 return status;
136} 136}
137 137
138static void netdev_stats_update(struct be_adapter *adapter) 138void netdev_stats_update(struct be_adapter *adapter)
139{ 139{
140 struct be_hw_stats *hw_stats = hw_stats_from_cmd(adapter->stats.cmd.va); 140 struct be_hw_stats *hw_stats = hw_stats_from_cmd(adapter->stats.cmd.va);
141 struct be_rxf_stats *rxf_stats = &hw_stats->rxf; 141 struct be_rxf_stats *rxf_stats = &hw_stats->rxf;
@@ -431,8 +431,7 @@ static int make_tx_wrbs(struct be_adapter *adapter,
431} 431}
432 432
433static netdev_tx_t be_xmit(struct sk_buff *skb, 433static netdev_tx_t be_xmit(struct sk_buff *skb,
434 struct net_device *netdev) 434 struct net_device *netdev)
435
436{ 435{
437 struct be_adapter *adapter = netdev_priv(netdev); 436 struct be_adapter *adapter = netdev_priv(netdev);
438 struct be_tx_obj *tx_obj = &adapter->tx_obj; 437 struct be_tx_obj *tx_obj = &adapter->tx_obj;
@@ -490,11 +489,11 @@ static int be_change_mtu(struct net_device *netdev, int new_mtu)
490 * program them in BE. If more than BE_NUM_VLANS_SUPPORTED are configured, 489 * program them in BE. If more than BE_NUM_VLANS_SUPPORTED are configured,
491 * set the BE in promiscuous VLAN mode. 490 * set the BE in promiscuous VLAN mode.
492 */ 491 */
493static void be_vid_config(struct net_device *netdev) 492static int be_vid_config(struct be_adapter *adapter)
494{ 493{
495 struct be_adapter *adapter = netdev_priv(netdev);
496 u16 vtag[BE_NUM_VLANS_SUPPORTED]; 494 u16 vtag[BE_NUM_VLANS_SUPPORTED];
497 u16 ntags = 0, i; 495 u16 ntags = 0, i;
496 int status;
498 497
499 if (adapter->num_vlans <= BE_NUM_VLANS_SUPPORTED) { 498 if (adapter->num_vlans <= BE_NUM_VLANS_SUPPORTED) {
500 /* Construct VLAN Table to give to HW */ 499 /* Construct VLAN Table to give to HW */
@@ -504,12 +503,13 @@ static void be_vid_config(struct net_device *netdev)
504 ntags++; 503 ntags++;
505 } 504 }
506 } 505 }
507 be_cmd_vlan_config(adapter, adapter->if_handle, 506 status = be_cmd_vlan_config(adapter, adapter->if_handle,
508 vtag, ntags, 1, 0); 507 vtag, ntags, 1, 0);
509 } else { 508 } else {
510 be_cmd_vlan_config(adapter, adapter->if_handle, 509 status = be_cmd_vlan_config(adapter, adapter->if_handle,
511 NULL, 0, 1, 1); 510 NULL, 0, 1, 1);
512 } 511 }
512 return status;
513} 513}
514 514
515static void be_vlan_register(struct net_device *netdev, struct vlan_group *grp) 515static void be_vlan_register(struct net_device *netdev, struct vlan_group *grp)
@@ -532,7 +532,7 @@ static void be_vlan_add_vid(struct net_device *netdev, u16 vid)
532 adapter->num_vlans++; 532 adapter->num_vlans++;
533 adapter->vlan_tag[vid] = 1; 533 adapter->vlan_tag[vid] = 1;
534 534
535 be_vid_config(netdev); 535 be_vid_config(adapter);
536} 536}
537 537
538static void be_vlan_rem_vid(struct net_device *netdev, u16 vid) 538static void be_vlan_rem_vid(struct net_device *netdev, u16 vid)
@@ -543,7 +543,7 @@ static void be_vlan_rem_vid(struct net_device *netdev, u16 vid)
543 adapter->vlan_tag[vid] = 0; 543 adapter->vlan_tag[vid] = 0;
544 544
545 vlan_group_set_device(adapter->vlan_grp, vid, NULL); 545 vlan_group_set_device(adapter->vlan_grp, vid, NULL);
546 be_vid_config(netdev); 546 be_vid_config(adapter);
547} 547}
548 548
549static void be_set_multicast_list(struct net_device *netdev) 549static void be_set_multicast_list(struct net_device *netdev)
@@ -1444,12 +1444,8 @@ static void be_worker(struct work_struct *work)
1444{ 1444{
1445 struct be_adapter *adapter = 1445 struct be_adapter *adapter =
1446 container_of(work, struct be_adapter, work.work); 1446 container_of(work, struct be_adapter, work.work);
1447 int status;
1448 1447
1449 /* Get Stats */ 1448 be_cmd_get_stats(adapter, &adapter->stats.cmd);
1450 status = be_cmd_get_stats(adapter, &adapter->stats.cmd);
1451 if (!status)
1452 netdev_stats_update(adapter);
1453 1449
1454 /* Set EQ delay */ 1450 /* Set EQ delay */
1455 be_rx_eqd_update(adapter); 1451 be_rx_eqd_update(adapter);
@@ -1622,11 +1618,6 @@ static int be_setup(struct be_adapter *adapter)
1622 if (status != 0) 1618 if (status != 0)
1623 goto do_none; 1619 goto do_none;
1624 1620
1625 be_vid_config(netdev);
1626
1627 status = be_cmd_set_flow_control(adapter, true, true);
1628 if (status != 0)
1629 goto if_destroy;
1630 1621
1631 status = be_tx_queues_create(adapter); 1622 status = be_tx_queues_create(adapter);
1632 if (status != 0) 1623 if (status != 0)
@@ -1640,8 +1631,17 @@ static int be_setup(struct be_adapter *adapter)
1640 if (status != 0) 1631 if (status != 0)
1641 goto rx_qs_destroy; 1632 goto rx_qs_destroy;
1642 1633
1634 status = be_vid_config(adapter);
1635 if (status != 0)
1636 goto mccqs_destroy;
1637
1638 status = be_cmd_set_flow_control(adapter, true, true);
1639 if (status != 0)
1640 goto mccqs_destroy;
1643 return 0; 1641 return 0;
1644 1642
1643mccqs_destroy:
1644 be_mcc_queues_destroy(adapter);
1645rx_qs_destroy: 1645rx_qs_destroy:
1646 be_rx_queues_destroy(adapter); 1646 be_rx_queues_destroy(adapter);
1647tx_qs_destroy: 1647tx_qs_destroy:
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index a7e731f8a0da..69c5b15e22da 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1093,15 +1093,8 @@ static struct slave *bond_find_best_slave(struct bonding *bond)
1093 return NULL; /* still no slave, return NULL */ 1093 return NULL; /* still no slave, return NULL */
1094 } 1094 }
1095 1095
1096 /*
1097 * first try the primary link; if arping, a link must tx/rx
1098 * traffic before it can be considered the curr_active_slave.
1099 * also, we would skip slaves between the curr_active_slave
1100 * and primary_slave that may be up and able to arp
1101 */
1102 if ((bond->primary_slave) && 1096 if ((bond->primary_slave) &&
1103 (!bond->params.arp_interval) && 1097 bond->primary_slave->link == BOND_LINK_UP) {
1104 (IS_UP(bond->primary_slave->dev))) {
1105 new_active = bond->primary_slave; 1098 new_active = bond->primary_slave;
1106 } 1099 }
1107 1100
@@ -1109,15 +1102,14 @@ static struct slave *bond_find_best_slave(struct bonding *bond)
1109 old_active = new_active; 1102 old_active = new_active;
1110 1103
1111 bond_for_each_slave_from(bond, new_active, i, old_active) { 1104 bond_for_each_slave_from(bond, new_active, i, old_active) {
1112 if (IS_UP(new_active->dev)) { 1105 if (new_active->link == BOND_LINK_UP) {
1113 if (new_active->link == BOND_LINK_UP) { 1106 return new_active;
1114 return new_active; 1107 } else if (new_active->link == BOND_LINK_BACK &&
1115 } else if (new_active->link == BOND_LINK_BACK) { 1108 IS_UP(new_active->dev)) {
1116 /* link up, but waiting for stabilization */ 1109 /* link up, but waiting for stabilization */
1117 if (new_active->delay < mintime) { 1110 if (new_active->delay < mintime) {
1118 mintime = new_active->delay; 1111 mintime = new_active->delay;
1119 bestslave = new_active; 1112 bestslave = new_active;
1120 }
1121 } 1113 }
1122 } 1114 }
1123 } 1115 }
@@ -1211,7 +1203,7 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
1211 write_unlock_bh(&bond->curr_slave_lock); 1203 write_unlock_bh(&bond->curr_slave_lock);
1212 read_unlock(&bond->lock); 1204 read_unlock(&bond->lock);
1213 1205
1214 netdev_bonding_change(bond->dev); 1206 netdev_bonding_change(bond->dev, NETDEV_BONDING_FAILOVER);
1215 1207
1216 read_lock(&bond->lock); 1208 read_lock(&bond->lock);
1217 write_lock_bh(&bond->curr_slave_lock); 1209 write_lock_bh(&bond->curr_slave_lock);
@@ -1469,14 +1461,17 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1469 */ 1461 */
1470 if (bond->slave_cnt == 0) { 1462 if (bond->slave_cnt == 0) {
1471 if (bond_dev->type != slave_dev->type) { 1463 if (bond_dev->type != slave_dev->type) {
1472 dev_close(bond_dev);
1473 pr_debug("%s: change device type from %d to %d\n", 1464 pr_debug("%s: change device type from %d to %d\n",
1474 bond_dev->name, bond_dev->type, slave_dev->type); 1465 bond_dev->name, bond_dev->type, slave_dev->type);
1466
1467 netdev_bonding_change(bond_dev, NETDEV_BONDING_OLDTYPE);
1468
1475 if (slave_dev->type != ARPHRD_ETHER) 1469 if (slave_dev->type != ARPHRD_ETHER)
1476 bond_setup_by_slave(bond_dev, slave_dev); 1470 bond_setup_by_slave(bond_dev, slave_dev);
1477 else 1471 else
1478 ether_setup(bond_dev); 1472 ether_setup(bond_dev);
1479 dev_open(bond_dev); 1473
1474 netdev_bonding_change(bond_dev, NETDEV_BONDING_NEWTYPE);
1480 } 1475 }
1481 } else if (bond_dev->type != slave_dev->type) { 1476 } else if (bond_dev->type != slave_dev->type) {
1482 pr_err(DRV_NAME ": %s ether type (%d) is different " 1477 pr_err(DRV_NAME ": %s ether type (%d) is different "
@@ -2929,18 +2924,6 @@ static int bond_ab_arp_inspect(struct bonding *bond, int delta_in_ticks)
2929 } 2924 }
2930 } 2925 }
2931 2926
2932 read_lock(&bond->curr_slave_lock);
2933
2934 /*
2935 * Trigger a commit if the primary option setting has changed.
2936 */
2937 if (bond->primary_slave &&
2938 (bond->primary_slave != bond->curr_active_slave) &&
2939 (bond->primary_slave->link == BOND_LINK_UP))
2940 commit++;
2941
2942 read_unlock(&bond->curr_slave_lock);
2943
2944 return commit; 2927 return commit;
2945} 2928}
2946 2929
@@ -2961,90 +2944,58 @@ static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks)
2961 continue; 2944 continue;
2962 2945
2963 case BOND_LINK_UP: 2946 case BOND_LINK_UP:
2964 write_lock_bh(&bond->curr_slave_lock); 2947 if ((!bond->curr_active_slave &&
2965 2948 time_before_eq(jiffies,
2966 if (!bond->curr_active_slave && 2949 dev_trans_start(slave->dev) +
2967 time_before_eq(jiffies, dev_trans_start(slave->dev) + 2950 delta_in_ticks)) ||
2968 delta_in_ticks)) { 2951 bond->curr_active_slave != slave) {
2969 slave->link = BOND_LINK_UP; 2952 slave->link = BOND_LINK_UP;
2970 bond_change_active_slave(bond, slave);
2971 bond->current_arp_slave = NULL; 2953 bond->current_arp_slave = NULL;
2972 2954
2973 pr_info(DRV_NAME 2955 pr_info(DRV_NAME
2974 ": %s: %s is up and now the " 2956 ": %s: link status definitely "
2975 "active interface\n", 2957 "up for interface %s.\n",
2976 bond->dev->name, slave->dev->name); 2958 bond->dev->name, slave->dev->name);
2977
2978 } else if (bond->curr_active_slave != slave) {
2979 /* this slave has just come up but we
2980 * already have a current slave; this can
2981 * also happen if bond_enslave adds a new
2982 * slave that is up while we are searching
2983 * for a new slave
2984 */
2985 slave->link = BOND_LINK_UP;
2986 bond_set_slave_inactive_flags(slave);
2987 bond->current_arp_slave = NULL;
2988 2959
2989 pr_info(DRV_NAME 2960 if (!bond->curr_active_slave ||
2990 ": %s: backup interface %s is now up\n", 2961 (slave == bond->primary_slave))
2991 bond->dev->name, slave->dev->name); 2962 goto do_failover;
2992 }
2993 2963
2994 write_unlock_bh(&bond->curr_slave_lock); 2964 }
2995 2965
2996 break; 2966 continue;
2997 2967
2998 case BOND_LINK_DOWN: 2968 case BOND_LINK_DOWN:
2999 if (slave->link_failure_count < UINT_MAX) 2969 if (slave->link_failure_count < UINT_MAX)
3000 slave->link_failure_count++; 2970 slave->link_failure_count++;
3001 2971
3002 slave->link = BOND_LINK_DOWN; 2972 slave->link = BOND_LINK_DOWN;
2973 bond_set_slave_inactive_flags(slave);
3003 2974
3004 if (slave == bond->curr_active_slave) { 2975 pr_info(DRV_NAME
3005 pr_info(DRV_NAME 2976 ": %s: link status definitely down for "
3006 ": %s: link status down for active " 2977 "interface %s, disabling it\n",
3007 "interface %s, disabling it\n", 2978 bond->dev->name, slave->dev->name);
3008 bond->dev->name, slave->dev->name);
3009
3010 bond_set_slave_inactive_flags(slave);
3011
3012 write_lock_bh(&bond->curr_slave_lock);
3013
3014 bond_select_active_slave(bond);
3015 if (bond->curr_active_slave)
3016 bond->curr_active_slave->jiffies =
3017 jiffies;
3018
3019 write_unlock_bh(&bond->curr_slave_lock);
3020 2979
2980 if (slave == bond->curr_active_slave) {
3021 bond->current_arp_slave = NULL; 2981 bond->current_arp_slave = NULL;
3022 2982 goto do_failover;
3023 } else if (slave->state == BOND_STATE_BACKUP) {
3024 pr_info(DRV_NAME
3025 ": %s: backup interface %s is now down\n",
3026 bond->dev->name, slave->dev->name);
3027
3028 bond_set_slave_inactive_flags(slave);
3029 } 2983 }
3030 break; 2984
2985 continue;
3031 2986
3032 default: 2987 default:
3033 pr_err(DRV_NAME 2988 pr_err(DRV_NAME
3034 ": %s: impossible: new_link %d on slave %s\n", 2989 ": %s: impossible: new_link %d on slave %s\n",
3035 bond->dev->name, slave->new_link, 2990 bond->dev->name, slave->new_link,
3036 slave->dev->name); 2991 slave->dev->name);
2992 continue;
3037 } 2993 }
3038 }
3039 2994
3040 /* 2995do_failover:
3041 * No race with changes to primary via sysfs, as we hold rtnl. 2996 ASSERT_RTNL();
3042 */
3043 if (bond->primary_slave &&
3044 (bond->primary_slave != bond->curr_active_slave) &&
3045 (bond->primary_slave->link == BOND_LINK_UP)) {
3046 write_lock_bh(&bond->curr_slave_lock); 2997 write_lock_bh(&bond->curr_slave_lock);
3047 bond_change_active_slave(bond, bond->primary_slave); 2998 bond_select_active_slave(bond);
3048 write_unlock_bh(&bond->curr_slave_lock); 2999 write_unlock_bh(&bond->curr_slave_lock);
3049 } 3000 }
3050 3001
diff --git a/drivers/net/can/vcan.c b/drivers/net/can/vcan.c
index 6971f6cd37fa..80ac56313981 100644
--- a/drivers/net/can/vcan.c
+++ b/drivers/net/can/vcan.c
@@ -80,7 +80,7 @@ static void vcan_rx(struct sk_buff *skb, struct net_device *dev)
80 skb->dev = dev; 80 skb->dev = dev;
81 skb->ip_summed = CHECKSUM_UNNECESSARY; 81 skb->ip_summed = CHECKSUM_UNNECESSARY;
82 82
83 netif_rx(skb); 83 netif_rx_ni(skb);
84} 84}
85 85
86static netdev_tx_t vcan_tx(struct sk_buff *skb, struct net_device *dev) 86static netdev_tx_t vcan_tx(struct sk_buff *skb, struct net_device *dev)
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
index 6158c0f3b205..f8f5772557ce 100644
--- a/drivers/net/igb/e1000_82575.c
+++ b/drivers/net/igb/e1000_82575.c
@@ -49,11 +49,10 @@ static s32 igb_read_phy_reg_sgmii_82575(struct e1000_hw *, u32, u16 *);
49static s32 igb_reset_hw_82575(struct e1000_hw *); 49static s32 igb_reset_hw_82575(struct e1000_hw *);
50static s32 igb_set_d0_lplu_state_82575(struct e1000_hw *, bool); 50static s32 igb_set_d0_lplu_state_82575(struct e1000_hw *, bool);
51static s32 igb_setup_copper_link_82575(struct e1000_hw *); 51static s32 igb_setup_copper_link_82575(struct e1000_hw *);
52static s32 igb_setup_fiber_serdes_link_82575(struct e1000_hw *); 52static s32 igb_setup_serdes_link_82575(struct e1000_hw *);
53static s32 igb_write_phy_reg_sgmii_82575(struct e1000_hw *, u32, u16); 53static s32 igb_write_phy_reg_sgmii_82575(struct e1000_hw *, u32, u16);
54static void igb_clear_hw_cntrs_82575(struct e1000_hw *); 54static void igb_clear_hw_cntrs_82575(struct e1000_hw *);
55static s32 igb_acquire_swfw_sync_82575(struct e1000_hw *, u16); 55static s32 igb_acquire_swfw_sync_82575(struct e1000_hw *, u16);
56static void igb_configure_pcs_link_82575(struct e1000_hw *);
57static s32 igb_get_pcs_speed_and_duplex_82575(struct e1000_hw *, u16 *, 56static s32 igb_get_pcs_speed_and_duplex_82575(struct e1000_hw *, u16 *,
58 u16 *); 57 u16 *);
59static s32 igb_get_phy_id_82575(struct e1000_hw *); 58static s32 igb_get_phy_id_82575(struct e1000_hw *);
@@ -105,16 +104,20 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
105 dev_spec->sgmii_active = false; 104 dev_spec->sgmii_active = false;
106 105
107 ctrl_ext = rd32(E1000_CTRL_EXT); 106 ctrl_ext = rd32(E1000_CTRL_EXT);
108 if ((ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK) == 107 switch (ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK) {
109 E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES) { 108 case E1000_CTRL_EXT_LINK_MODE_SGMII:
110 hw->phy.media_type = e1000_media_type_internal_serdes;
111 ctrl_ext |= E1000_CTRL_I2C_ENA;
112 } else if (ctrl_ext & E1000_CTRL_EXT_LINK_MODE_SGMII) {
113 dev_spec->sgmii_active = true; 109 dev_spec->sgmii_active = true;
114 ctrl_ext |= E1000_CTRL_I2C_ENA; 110 ctrl_ext |= E1000_CTRL_I2C_ENA;
115 } else { 111 break;
112 case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES:
113 hw->phy.media_type = e1000_media_type_internal_serdes;
114 ctrl_ext |= E1000_CTRL_I2C_ENA;
115 break;
116 default:
116 ctrl_ext &= ~E1000_CTRL_I2C_ENA; 117 ctrl_ext &= ~E1000_CTRL_I2C_ENA;
118 break;
117 } 119 }
120
118 wr32(E1000_CTRL_EXT, ctrl_ext); 121 wr32(E1000_CTRL_EXT, ctrl_ext);
119 122
120 /* Set mta register count */ 123 /* Set mta register count */
@@ -134,7 +137,7 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
134 mac->ops.setup_physical_interface = 137 mac->ops.setup_physical_interface =
135 (hw->phy.media_type == e1000_media_type_copper) 138 (hw->phy.media_type == e1000_media_type_copper)
136 ? igb_setup_copper_link_82575 139 ? igb_setup_copper_link_82575
137 : igb_setup_fiber_serdes_link_82575; 140 : igb_setup_serdes_link_82575;
138 141
139 /* NVM initialization */ 142 /* NVM initialization */
140 eecd = rd32(E1000_EECD); 143 eecd = rd32(E1000_EECD);
@@ -379,6 +382,7 @@ static s32 igb_get_phy_id_82575(struct e1000_hw *hw)
379 struct e1000_phy_info *phy = &hw->phy; 382 struct e1000_phy_info *phy = &hw->phy;
380 s32 ret_val = 0; 383 s32 ret_val = 0;
381 u16 phy_id; 384 u16 phy_id;
385 u32 ctrl_ext;
382 386
383 /* 387 /*
384 * For SGMII PHYs, we try the list of possible addresses until 388 * For SGMII PHYs, we try the list of possible addresses until
@@ -393,6 +397,12 @@ static s32 igb_get_phy_id_82575(struct e1000_hw *hw)
393 goto out; 397 goto out;
394 } 398 }
395 399
400 /* Power on sgmii phy if it is disabled */
401 ctrl_ext = rd32(E1000_CTRL_EXT);
402 wr32(E1000_CTRL_EXT, ctrl_ext & ~E1000_CTRL_EXT_SDP3_DATA);
403 wrfl();
404 msleep(300);
405
396 /* 406 /*
397 * The address field in the I2CCMD register is 3 bits and 0 is invalid. 407 * The address field in the I2CCMD register is 3 bits and 0 is invalid.
398 * Therefore, we need to test 1-7 408 * Therefore, we need to test 1-7
@@ -418,9 +428,12 @@ static s32 igb_get_phy_id_82575(struct e1000_hw *hw)
418 phy->addr = 0; 428 phy->addr = 0;
419 ret_val = -E1000_ERR_PHY; 429 ret_val = -E1000_ERR_PHY;
420 goto out; 430 goto out;
431 } else {
432 ret_val = igb_get_phy_id(hw);
421 } 433 }
422 434
423 ret_val = igb_get_phy_id(hw); 435 /* restore previous sfp cage power state */
436 wr32(E1000_CTRL_EXT, ctrl_ext);
424 437
425out: 438out:
426 return ret_val; 439 return ret_val;
@@ -766,17 +779,18 @@ static s32 igb_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw, u16 *speed,
766} 779}
767 780
768/** 781/**
769 * igb_shutdown_fiber_serdes_link_82575 - Remove link during power down 782 * igb_shutdown_serdes_link_82575 - Remove link during power down
770 * @hw: pointer to the HW structure 783 * @hw: pointer to the HW structure
771 * 784 *
772 * In the case of fiber serdes, shut down optics and PCS on driver unload 785 * In the case of fiber serdes, shut down optics and PCS on driver unload
773 * when management pass thru is not enabled. 786 * when management pass thru is not enabled.
774 **/ 787 **/
775void igb_shutdown_fiber_serdes_link_82575(struct e1000_hw *hw) 788void igb_shutdown_serdes_link_82575(struct e1000_hw *hw)
776{ 789{
777 u32 reg; 790 u32 reg;
778 791
779 if (hw->phy.media_type != e1000_media_type_internal_serdes) 792 if (hw->phy.media_type != e1000_media_type_internal_serdes ||
793 igb_sgmii_active_82575(hw))
780 return; 794 return;
781 795
782 /* if the management interface is not enabled, then power down */ 796 /* if the management interface is not enabled, then power down */
@@ -788,7 +802,7 @@ void igb_shutdown_fiber_serdes_link_82575(struct e1000_hw *hw)
788 802
789 /* shutdown the laser */ 803 /* shutdown the laser */
790 reg = rd32(E1000_CTRL_EXT); 804 reg = rd32(E1000_CTRL_EXT);
791 reg |= E1000_CTRL_EXT_SDP7_DATA; 805 reg |= E1000_CTRL_EXT_SDP3_DATA;
792 wr32(E1000_CTRL_EXT, reg); 806 wr32(E1000_CTRL_EXT, reg);
793 807
794 /* flush the write to verify completion */ 808 /* flush the write to verify completion */
@@ -927,6 +941,17 @@ static s32 igb_setup_copper_link_82575(struct e1000_hw *hw)
927 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX); 941 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
928 wr32(E1000_CTRL, ctrl); 942 wr32(E1000_CTRL, ctrl);
929 943
944 ret_val = igb_setup_serdes_link_82575(hw);
945 if (ret_val)
946 goto out;
947
948 if (igb_sgmii_active_82575(hw) && !hw->phy.reset_disable) {
949 ret_val = hw->phy.ops.reset(hw);
950 if (ret_val) {
951 hw_dbg("Error resetting the PHY.\n");
952 goto out;
953 }
954 }
930 switch (hw->phy.type) { 955 switch (hw->phy.type) {
931 case e1000_phy_m88: 956 case e1000_phy_m88:
932 ret_val = igb_copper_link_setup_m88(hw); 957 ret_val = igb_copper_link_setup_m88(hw);
@@ -963,8 +988,6 @@ static s32 igb_setup_copper_link_82575(struct e1000_hw *hw)
963 } 988 }
964 } 989 }
965 990
966 igb_configure_pcs_link_82575(hw);
967
968 /* 991 /*
969 * Check link status. Wait up to 100 microseconds for link to become 992 * Check link status. Wait up to 100 microseconds for link to become
970 * valid. 993 * valid.
@@ -987,14 +1010,18 @@ out:
987} 1010}
988 1011
989/** 1012/**
990 * igb_setup_fiber_serdes_link_82575 - Setup link for fiber/serdes 1013 * igb_setup_serdes_link_82575 - Setup link for fiber/serdes
991 * @hw: pointer to the HW structure 1014 * @hw: pointer to the HW structure
992 * 1015 *
993 * Configures speed and duplex for fiber and serdes links. 1016 * Configures speed and duplex for fiber and serdes links.
994 **/ 1017 **/
995static s32 igb_setup_fiber_serdes_link_82575(struct e1000_hw *hw) 1018static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw)
996{ 1019{
997 u32 reg; 1020 u32 ctrl_reg, reg;
1021
1022 if ((hw->phy.media_type != e1000_media_type_internal_serdes) &&
1023 !igb_sgmii_active_82575(hw))
1024 return 0;
998 1025
999 /* 1026 /*
1000 * On the 82575, SerDes loopback mode persists until it is 1027 * On the 82575, SerDes loopback mode persists until it is
@@ -1004,26 +1031,38 @@ static s32 igb_setup_fiber_serdes_link_82575(struct e1000_hw *hw)
1004 */ 1031 */
1005 wr32(E1000_SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK); 1032 wr32(E1000_SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK);
1006 1033
1007 /* Force link up, set 1gb, set both sw defined pins */ 1034 /* power on the sfp cage if present */
1008 reg = rd32(E1000_CTRL); 1035 reg = rd32(E1000_CTRL_EXT);
1009 reg |= E1000_CTRL_SLU | 1036 reg &= ~E1000_CTRL_EXT_SDP3_DATA;
1010 E1000_CTRL_SPD_1000 | 1037 wr32(E1000_CTRL_EXT, reg);
1011 E1000_CTRL_FRCSPD | 1038
1012 E1000_CTRL_SWDPIN0 | 1039 ctrl_reg = rd32(E1000_CTRL);
1013 E1000_CTRL_SWDPIN1; 1040 ctrl_reg |= E1000_CTRL_SLU;
1014 wr32(E1000_CTRL, reg); 1041
1015 1042 if (hw->mac.type == e1000_82575 || hw->mac.type == e1000_82576) {
1016 /* Power on phy for 82576 fiber adapters */ 1043 /* set both sw defined pins */
1017 if (hw->mac.type == e1000_82576) { 1044 ctrl_reg |= E1000_CTRL_SWDPIN0 | E1000_CTRL_SWDPIN1;
1018 reg = rd32(E1000_CTRL_EXT); 1045
1019 reg &= ~E1000_CTRL_EXT_SDP7_DATA; 1046 /* Set switch control to serdes energy detect */
1020 wr32(E1000_CTRL_EXT, reg); 1047 reg = rd32(E1000_CONNSW);
1048 reg |= E1000_CONNSW_ENRGSRC;
1049 wr32(E1000_CONNSW, reg);
1050 }
1051
1052 reg = rd32(E1000_PCS_LCTL);
1053
1054 if (igb_sgmii_active_82575(hw)) {
1055 /* allow time for SFP cage to power up phy */
1056 msleep(300);
1057
1058 /* AN time out should be disabled for SGMII mode */
1059 reg &= ~(E1000_PCS_LCTL_AN_TIMEOUT);
1060 } else {
1061 ctrl_reg |= E1000_CTRL_SPD_1000 | E1000_CTRL_FRCSPD |
1062 E1000_CTRL_FD | E1000_CTRL_FRCDPX;
1021 } 1063 }
1022 1064
1023 /* Set switch control to serdes energy detect */ 1065 wr32(E1000_CTRL, ctrl_reg);
1024 reg = rd32(E1000_CONNSW);
1025 reg |= E1000_CONNSW_ENRGSRC;
1026 wr32(E1000_CONNSW, reg);
1027 1066
1028 /* 1067 /*
1029 * New SerDes mode allows for forcing speed or autonegotiating speed 1068 * New SerDes mode allows for forcing speed or autonegotiating speed
@@ -1031,12 +1070,21 @@ static s32 igb_setup_fiber_serdes_link_82575(struct e1000_hw *hw)
1031 * mode that will be compatible with older link partners and switches. 1070 * mode that will be compatible with older link partners and switches.
1032 * However, both are supported by the hardware and some drivers/tools. 1071 * However, both are supported by the hardware and some drivers/tools.
1033 */ 1072 */
1034 reg = rd32(E1000_PCS_LCTL);
1035 1073
1036 reg &= ~(E1000_PCS_LCTL_AN_ENABLE | E1000_PCS_LCTL_FLV_LINK_UP | 1074 reg &= ~(E1000_PCS_LCTL_AN_ENABLE | E1000_PCS_LCTL_FLV_LINK_UP |
1037 E1000_PCS_LCTL_FSD | E1000_PCS_LCTL_FORCE_LINK); 1075 E1000_PCS_LCTL_FSD | E1000_PCS_LCTL_FORCE_LINK);
1038 1076
1039 if (hw->mac.autoneg) { 1077 /*
1078 * We force flow control to prevent the CTRL register values from being
1079 * overwritten by the autonegotiated flow control values
1080 */
1081 reg |= E1000_PCS_LCTL_FORCE_FCTRL;
1082
1083 /*
1084 * we always set sgmii to autoneg since it is the phy that will be
1085 * forcing the link and the serdes is just a go-between
1086 */
1087 if (hw->mac.autoneg || igb_sgmii_active_82575(hw)) {
1040 /* Set PCS register for autoneg */ 1088 /* Set PCS register for autoneg */
1041 reg |= E1000_PCS_LCTL_FSV_1000 | /* Force 1000 */ 1089 reg |= E1000_PCS_LCTL_FSV_1000 | /* Force 1000 */
1042 E1000_PCS_LCTL_FDV_FULL | /* SerDes Full duplex */ 1090 E1000_PCS_LCTL_FDV_FULL | /* SerDes Full duplex */
@@ -1053,75 +1101,12 @@ static s32 igb_setup_fiber_serdes_link_82575(struct e1000_hw *hw)
1053 hw_dbg("Configuring Forced Link; PCS_LCTL = 0x%08X\n", reg); 1101 hw_dbg("Configuring Forced Link; PCS_LCTL = 0x%08X\n", reg);
1054 } 1102 }
1055 1103
1056 if (hw->mac.type == e1000_82576) {
1057 reg |= E1000_PCS_LCTL_FORCE_FCTRL;
1058 igb_force_mac_fc(hw);
1059 }
1060
1061 wr32(E1000_PCS_LCTL, reg); 1104 wr32(E1000_PCS_LCTL, reg);
1062 1105
1063 return 0; 1106 if (!igb_sgmii_active_82575(hw))
1064} 1107 igb_force_mac_fc(hw);
1065
1066/**
1067 * igb_configure_pcs_link_82575 - Configure PCS link
1068 * @hw: pointer to the HW structure
1069 *
1070 * Configure the physical coding sub-layer (PCS) link. The PCS link is
1071 * only used on copper connections where the serialized gigabit media
1072 * independent interface (sgmii) is being used. Configures the link
1073 * for auto-negotiation or forces speed/duplex.
1074 **/
1075static void igb_configure_pcs_link_82575(struct e1000_hw *hw)
1076{
1077 struct e1000_mac_info *mac = &hw->mac;
1078 u32 reg = 0;
1079
1080 if (hw->phy.media_type != e1000_media_type_copper ||
1081 !(igb_sgmii_active_82575(hw)))
1082 return;
1083
1084 /* For SGMII, we need to issue a PCS autoneg restart */
1085 reg = rd32(E1000_PCS_LCTL);
1086
1087 /* AN time out should be disabled for SGMII mode */
1088 reg &= ~(E1000_PCS_LCTL_AN_TIMEOUT);
1089
1090 if (mac->autoneg) {
1091 /* Make sure forced speed and force link are not set */
1092 reg &= ~(E1000_PCS_LCTL_FSD | E1000_PCS_LCTL_FORCE_LINK);
1093
1094 /*
1095 * The PHY should be setup prior to calling this function.
1096 * All we need to do is restart autoneg and enable autoneg.
1097 */
1098 reg |= E1000_PCS_LCTL_AN_RESTART | E1000_PCS_LCTL_AN_ENABLE;
1099 } else {
1100 /* Set PCS register for forced speed */
1101
1102 /* Turn off bits for full duplex, speed, and autoneg */
1103 reg &= ~(E1000_PCS_LCTL_FSV_1000 |
1104 E1000_PCS_LCTL_FSV_100 |
1105 E1000_PCS_LCTL_FDV_FULL |
1106 E1000_PCS_LCTL_AN_ENABLE);
1107
1108 /* Check for duplex first */
1109 if (mac->forced_speed_duplex & E1000_ALL_FULL_DUPLEX)
1110 reg |= E1000_PCS_LCTL_FDV_FULL;
1111
1112 /* Now set speed */
1113 if (mac->forced_speed_duplex & E1000_ALL_100_SPEED)
1114 reg |= E1000_PCS_LCTL_FSV_100;
1115
1116 /* Force speed and force link */
1117 reg |= E1000_PCS_LCTL_FSD |
1118 E1000_PCS_LCTL_FORCE_LINK |
1119 E1000_PCS_LCTL_FLV_LINK_UP;
1120 1108
1121 hw_dbg("Wrote 0x%08X to PCS_LCTL to configure forced link\n", 1109 return 0;
1122 reg);
1123 }
1124 wr32(E1000_PCS_LCTL, reg);
1125} 1110}
1126 1111
1127/** 1112/**
@@ -1248,7 +1233,8 @@ static void igb_clear_hw_cntrs_82575(struct e1000_hw *hw)
1248 temp = rd32(E1000_LENERRS); 1233 temp = rd32(E1000_LENERRS);
1249 1234
1250 /* This register should not be read in copper configurations */ 1235 /* This register should not be read in copper configurations */
1251 if (hw->phy.media_type == e1000_media_type_internal_serdes) 1236 if (hw->phy.media_type == e1000_media_type_internal_serdes ||
1237 igb_sgmii_active_82575(hw))
1252 temp = rd32(E1000_SCVPC); 1238 temp = rd32(E1000_SCVPC);
1253} 1239}
1254 1240
diff --git a/drivers/net/igb/e1000_82575.h b/drivers/net/igb/e1000_82575.h
index 8a1e6597061f..ebd146fd4e15 100644
--- a/drivers/net/igb/e1000_82575.h
+++ b/drivers/net/igb/e1000_82575.h
@@ -28,7 +28,7 @@
28#ifndef _E1000_82575_H_ 28#ifndef _E1000_82575_H_
29#define _E1000_82575_H_ 29#define _E1000_82575_H_
30 30
31extern void igb_shutdown_fiber_serdes_link_82575(struct e1000_hw *hw); 31extern void igb_shutdown_serdes_link_82575(struct e1000_hw *hw);
32extern void igb_rx_fifo_flush_82575(struct e1000_hw *hw); 32extern void igb_rx_fifo_flush_82575(struct e1000_hw *hw);
33 33
34#define ID_LED_DEFAULT_82575_SERDES ((ID_LED_DEF1_DEF2 << 12) | \ 34#define ID_LED_DEFAULT_82575_SERDES ((ID_LED_DEF1_DEF2 << 12) | \
diff --git a/drivers/net/igb/e1000_defines.h b/drivers/net/igb/e1000_defines.h
index c85829355d50..cb916833f303 100644
--- a/drivers/net/igb/e1000_defines.h
+++ b/drivers/net/igb/e1000_defines.h
@@ -44,7 +44,7 @@
44#define E1000_WUFC_BC 0x00000010 /* Broadcast Wakeup Enable */ 44#define E1000_WUFC_BC 0x00000010 /* Broadcast Wakeup Enable */
45 45
46/* Extended Device Control */ 46/* Extended Device Control */
47#define E1000_CTRL_EXT_SDP7_DATA 0x00000080 /* Value of SW Defineable Pin 7 */ 47#define E1000_CTRL_EXT_SDP3_DATA 0x00000080 /* Value of SW Defineable Pin 3 */
48/* Physical Func Reset Done Indication */ 48/* Physical Func Reset Done Indication */
49#define E1000_CTRL_EXT_PFRSTD 0x00004000 49#define E1000_CTRL_EXT_PFRSTD 0x00004000
50#define E1000_CTRL_EXT_LINK_MODE_MASK 0x00C00000 50#define E1000_CTRL_EXT_LINK_MODE_MASK 0x00C00000
diff --git a/drivers/net/igb/e1000_phy.c b/drivers/net/igb/e1000_phy.c
index c1f4da630420..ee460600e74b 100644
--- a/drivers/net/igb/e1000_phy.c
+++ b/drivers/net/igb/e1000_phy.c
@@ -1565,9 +1565,12 @@ out:
1565 **/ 1565 **/
1566s32 igb_phy_sw_reset(struct e1000_hw *hw) 1566s32 igb_phy_sw_reset(struct e1000_hw *hw)
1567{ 1567{
1568 s32 ret_val; 1568 s32 ret_val = 0;
1569 u16 phy_ctrl; 1569 u16 phy_ctrl;
1570 1570
1571 if (!(hw->phy.ops.read_reg))
1572 goto out;
1573
1571 ret_val = hw->phy.ops.read_reg(hw, PHY_CONTROL, &phy_ctrl); 1574 ret_val = hw->phy.ops.read_reg(hw, PHY_CONTROL, &phy_ctrl);
1572 if (ret_val) 1575 if (ret_val)
1573 goto out; 1576 goto out;
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 943186b78483..d2639c4a086d 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -5320,7 +5320,7 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake)
5320 5320
5321 *enable_wake = wufc || adapter->en_mng_pt; 5321 *enable_wake = wufc || adapter->en_mng_pt;
5322 if (!*enable_wake) 5322 if (!*enable_wake)
5323 igb_shutdown_fiber_serdes_link_82575(hw); 5323 igb_shutdown_serdes_link_82575(hw);
5324 5324
5325 /* Release control of h/w to f/w. If f/w is AMT enabled, this 5325 /* Release control of h/w to f/w. If f/w is AMT enabled, this
5326 * would have already happened in close and is redundant. */ 5326 * would have already happened in close and is redundant. */
diff --git a/drivers/net/ixgbe/ixgbe_82598.c b/drivers/net/ixgbe/ixgbe_82598.c
index cb7f0c3c6e16..56b12f3192f1 100644
--- a/drivers/net/ixgbe/ixgbe_82598.c
+++ b/drivers/net/ixgbe/ixgbe_82598.c
@@ -322,14 +322,16 @@ static enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw)
322 break; 322 break;
323 case IXGBE_DEV_ID_82598AF_DUAL_PORT: 323 case IXGBE_DEV_ID_82598AF_DUAL_PORT:
324 case IXGBE_DEV_ID_82598AF_SINGLE_PORT: 324 case IXGBE_DEV_ID_82598AF_SINGLE_PORT:
325 case IXGBE_DEV_ID_82598EB_CX4:
326 case IXGBE_DEV_ID_82598_CX4_DUAL_PORT:
327 case IXGBE_DEV_ID_82598_DA_DUAL_PORT: 325 case IXGBE_DEV_ID_82598_DA_DUAL_PORT:
328 case IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM: 326 case IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM:
329 case IXGBE_DEV_ID_82598EB_XF_LR: 327 case IXGBE_DEV_ID_82598EB_XF_LR:
330 case IXGBE_DEV_ID_82598EB_SFP_LOM: 328 case IXGBE_DEV_ID_82598EB_SFP_LOM:
331 media_type = ixgbe_media_type_fiber; 329 media_type = ixgbe_media_type_fiber;
332 break; 330 break;
331 case IXGBE_DEV_ID_82598EB_CX4:
332 case IXGBE_DEV_ID_82598_CX4_DUAL_PORT:
333 media_type = ixgbe_media_type_cx4;
334 break;
333 case IXGBE_DEV_ID_82598AT: 335 case IXGBE_DEV_ID_82598AT:
334 case IXGBE_DEV_ID_82598AT2: 336 case IXGBE_DEV_ID_82598AT2:
335 media_type = ixgbe_media_type_copper; 337 media_type = ixgbe_media_type_copper;
diff --git a/drivers/net/ixgbe/ixgbe_82599.c b/drivers/net/ixgbe/ixgbe_82599.c
index 61af47e75aa1..2ec58dcdb82b 100644
--- a/drivers/net/ixgbe/ixgbe_82599.c
+++ b/drivers/net/ixgbe/ixgbe_82599.c
@@ -337,6 +337,9 @@ static enum ixgbe_media_type ixgbe_get_media_type_82599(struct ixgbe_hw *hw)
337 case IXGBE_DEV_ID_82599_SFP: 337 case IXGBE_DEV_ID_82599_SFP:
338 media_type = ixgbe_media_type_fiber; 338 media_type = ixgbe_media_type_fiber;
339 break; 339 break;
340 case IXGBE_DEV_ID_82599_CX4:
341 media_type = ixgbe_media_type_cx4;
342 break;
340 default: 343 default:
341 media_type = ixgbe_media_type_unknown; 344 media_type = ixgbe_media_type_unknown;
342 break; 345 break;
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 45bf8b9716e3..59ad9590e700 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -97,6 +97,8 @@ static struct pci_device_id ixgbe_pci_tbl[] = {
97 board_82599 }, 97 board_82599 },
98 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_SFP), 98 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_SFP),
99 board_82599 }, 99 board_82599 },
100 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_CX4),
101 board_82599 },
100 102
101 /* required last entry */ 103 /* required last entry */
102 {0, } 104 {0, }
@@ -2055,6 +2057,8 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
2055 2057
2056 if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) 2058 if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED)
2057 rx_ring->flags |= IXGBE_RING_RX_PS_ENABLED; 2059 rx_ring->flags |= IXGBE_RING_RX_PS_ENABLED;
2060 else
2061 rx_ring->flags &= ~IXGBE_RING_RX_PS_ENABLED;
2058 2062
2059#ifdef IXGBE_FCOE 2063#ifdef IXGBE_FCOE
2060 if (netdev->features & NETIF_F_FCOE_MTU) { 2064 if (netdev->features & NETIF_F_FCOE_MTU) {
diff --git a/drivers/net/ixgbe/ixgbe_type.h b/drivers/net/ixgbe/ixgbe_type.h
index 8ba90eec1dc9..8761d7899f7d 100644
--- a/drivers/net/ixgbe/ixgbe_type.h
+++ b/drivers/net/ixgbe/ixgbe_type.h
@@ -49,6 +49,7 @@
49#define IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM 0x10E1 49#define IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM 0x10E1
50#define IXGBE_DEV_ID_82598EB_XF_LR 0x10F4 50#define IXGBE_DEV_ID_82598EB_XF_LR 0x10F4
51#define IXGBE_DEV_ID_82599_KX4 0x10F7 51#define IXGBE_DEV_ID_82599_KX4 0x10F7
52#define IXGBE_DEV_ID_82599_CX4 0x10F9
52#define IXGBE_DEV_ID_82599_SFP 0x10FB 53#define IXGBE_DEV_ID_82599_SFP 0x10FB
53#define IXGBE_DEV_ID_82599_XAUI_LOM 0x10FC 54#define IXGBE_DEV_ID_82599_XAUI_LOM 0x10FC
54 55
@@ -2143,6 +2144,7 @@ enum ixgbe_media_type {
2143 ixgbe_media_type_fiber, 2144 ixgbe_media_type_fiber,
2144 ixgbe_media_type_copper, 2145 ixgbe_media_type_copper,
2145 ixgbe_media_type_backplane, 2146 ixgbe_media_type_backplane,
2147 ixgbe_media_type_cx4,
2146 ixgbe_media_type_virtual 2148 ixgbe_media_type_virtual
2147}; 2149};
2148 2150
diff --git a/drivers/net/mlx4/catas.c b/drivers/net/mlx4/catas.c
index aa9674b7f19c..f599294fa8ab 100644
--- a/drivers/net/mlx4/catas.c
+++ b/drivers/net/mlx4/catas.c
@@ -96,12 +96,17 @@ static void catas_reset(struct work_struct *work)
96 spin_unlock_irq(&catas_lock); 96 spin_unlock_irq(&catas_lock);
97 97
98 list_for_each_entry_safe(priv, tmppriv, &tlist, catas_err.list) { 98 list_for_each_entry_safe(priv, tmppriv, &tlist, catas_err.list) {
99 struct pci_dev *pdev = priv->dev.pdev;
100
99 ret = mlx4_restart_one(priv->dev.pdev); 101 ret = mlx4_restart_one(priv->dev.pdev);
100 dev = &priv->dev; 102 /* 'priv' now is not valid */
101 if (ret) 103 if (ret)
102 mlx4_err(dev, "Reset failed (%d)\n", ret); 104 printk(KERN_ERR "mlx4 %s: Reset failed (%d)\n",
103 else 105 pci_name(pdev), ret);
106 else {
107 dev = pci_get_drvdata(pdev);
104 mlx4_dbg(dev, "Reset succeeded\n"); 108 mlx4_dbg(dev, "Reset succeeded\n");
109 }
105 } 110 }
106} 111}
107 112
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index 90a94d215831..97db1c732342 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -1750,11 +1750,11 @@ static struct pcmcia_device_id pcnet_ids[] = {
1750 PCMCIA_DEVICE_PROD_ID2("EN-6200P2", 0xa996d078), 1750 PCMCIA_DEVICE_PROD_ID2("EN-6200P2", 0xa996d078),
1751 /* too generic! */ 1751 /* too generic! */
1752 /* PCMCIA_DEVICE_PROD_ID12("PCMCIA", "10/100 Ethernet Card", 0x281f1c5d, 0x11b0ffc0), */ 1752 /* PCMCIA_DEVICE_PROD_ID12("PCMCIA", "10/100 Ethernet Card", 0x281f1c5d, 0x11b0ffc0), */
1753 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "PCMCIA", "EN2218-LAN/MODEM", 0x281f1c5d, 0x570f348e, "PCMLM28.cis"), 1753 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "PCMCIA", "EN2218-LAN/MODEM", 0x281f1c5d, 0x570f348e, "cis/PCMLM28.cis"),
1754 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "PCMCIA", "UE2218-LAN/MODEM", 0x281f1c5d, 0x6fdcacee, "PCMLM28.cis"), 1754 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "PCMCIA", "UE2218-LAN/MODEM", 0x281f1c5d, 0x6fdcacee, "cis/PCMLM28.cis"),
1755 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "PCMLM28.cis"), 1755 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "cis/PCMLM28.cis"),
1756 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "Psion Dacom", "Gold Card V34 Ethernet GSM", 0xf5f025c2, 0x4ae85d35, "PCMLM28.cis"), 1756 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "Psion Dacom", "Gold Card V34 Ethernet GSM", 0xf5f025c2, 0x4ae85d35, "cis/PCMLM28.cis"),
1757 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "LINKSYS", "PCMLM28", 0xf7cb0b07, 0x66881874, "PCMLM28.cis"), 1757 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "LINKSYS", "PCMLM28", 0xf7cb0b07, 0x66881874, "cis/PCMLM28.cis"),
1758 PCMCIA_MFC_DEVICE_CIS_PROD_ID12(0, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "DP83903.cis"), 1758 PCMCIA_MFC_DEVICE_CIS_PROD_ID12(0, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "DP83903.cis"),
1759 PCMCIA_MFC_DEVICE_CIS_PROD_ID4(0, "NSC MF LAN/Modem", 0x58fc6056, "DP83903.cis"), 1759 PCMCIA_MFC_DEVICE_CIS_PROD_ID4(0, "NSC MF LAN/Modem", 0x58fc6056, "DP83903.cis"),
1760 PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0175, 0x0000, "DP83903.cis"), 1760 PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0175, 0x0000, "DP83903.cis"),
diff --git a/drivers/net/pppol2tp.c b/drivers/net/pppol2tp.c
index e0f9219a0aea..cc394d073755 100644
--- a/drivers/net/pppol2tp.c
+++ b/drivers/net/pppol2tp.c
@@ -229,7 +229,7 @@ static void pppol2tp_tunnel_free(struct pppol2tp_tunnel *tunnel);
229static atomic_t pppol2tp_tunnel_count; 229static atomic_t pppol2tp_tunnel_count;
230static atomic_t pppol2tp_session_count; 230static atomic_t pppol2tp_session_count;
231static struct ppp_channel_ops pppol2tp_chan_ops = { pppol2tp_xmit , NULL }; 231static struct ppp_channel_ops pppol2tp_chan_ops = { pppol2tp_xmit , NULL };
232static struct proto_ops pppol2tp_ops; 232static const struct proto_ops pppol2tp_ops;
233 233
234/* per-net private data for this module */ 234/* per-net private data for this module */
235static int pppol2tp_net_id; 235static int pppol2tp_net_id;
@@ -2574,7 +2574,7 @@ static const struct file_operations pppol2tp_proc_fops = {
2574 * Init and cleanup 2574 * Init and cleanup
2575 *****************************************************************************/ 2575 *****************************************************************************/
2576 2576
2577static struct proto_ops pppol2tp_ops = { 2577static const struct proto_ops pppol2tp_ops = {
2578 .family = AF_PPPOX, 2578 .family = AF_PPPOX,
2579 .owner = THIS_MODULE, 2579 .owner = THIS_MODULE,
2580 .release = pppol2tp_release, 2580 .release = pppol2tp_release,
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 00bc65a0aac9..4bb52e9cd371 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -65,8 +65,8 @@
65#define RX_DEF_PENDING RX_MAX_PENDING 65#define RX_DEF_PENDING RX_MAX_PENDING
66 66
67/* This is the worst case number of transmit list elements for a single skb: 67/* This is the worst case number of transmit list elements for a single skb:
68 VLAN + TSO + CKSUM + Data + skb_frags * DMA */ 68 VLAN:GSO + CKSUM + Data + skb_frags * DMA */
69#define MAX_SKB_TX_LE (4 + (sizeof(dma_addr_t)/sizeof(u32))*MAX_SKB_FRAGS) 69#define MAX_SKB_TX_LE (2 + (sizeof(dma_addr_t)/sizeof(u32))*(MAX_SKB_FRAGS+1))
70#define TX_MIN_PENDING (MAX_SKB_TX_LE+1) 70#define TX_MIN_PENDING (MAX_SKB_TX_LE+1)
71#define TX_MAX_PENDING 4096 71#define TX_MAX_PENDING 4096
72#define TX_DEF_PENDING 127 72#define TX_DEF_PENDING 127
@@ -1567,11 +1567,13 @@ static unsigned tx_le_req(const struct sk_buff *skb)
1567{ 1567{
1568 unsigned count; 1568 unsigned count;
1569 1569
1570 count = sizeof(dma_addr_t) / sizeof(u32); 1570 count = (skb_shinfo(skb)->nr_frags + 1)
1571 count += skb_shinfo(skb)->nr_frags * count; 1571 * (sizeof(dma_addr_t) / sizeof(u32));
1572 1572
1573 if (skb_is_gso(skb)) 1573 if (skb_is_gso(skb))
1574 ++count; 1574 ++count;
1575 else if (sizeof(dma_addr_t) == sizeof(u32))
1576 ++count; /* possible vlan */
1575 1577
1576 if (skb->ip_summed == CHECKSUM_PARTIAL) 1578 if (skb->ip_summed == CHECKSUM_PARTIAL)
1577 ++count; 1579 ++count;
@@ -4548,16 +4550,18 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
4548 if (hw->ports > 1) { 4550 if (hw->ports > 1) {
4549 struct net_device *dev1; 4551 struct net_device *dev1;
4550 4552
4553 err = -ENOMEM;
4551 dev1 = sky2_init_netdev(hw, 1, using_dac, wol_default); 4554 dev1 = sky2_init_netdev(hw, 1, using_dac, wol_default);
4552 if (!dev1) 4555 if (dev1 && (err = register_netdev(dev1)) == 0)
4553 dev_warn(&pdev->dev, "allocation for second device failed\n"); 4556 sky2_show_addr(dev1);
4554 else if ((err = register_netdev(dev1))) { 4557 else {
4555 dev_warn(&pdev->dev, 4558 dev_warn(&pdev->dev,
4556 "register of second port failed (%d)\n", err); 4559 "register of second port failed (%d)\n", err);
4557 hw->dev[1] = NULL; 4560 hw->dev[1] = NULL;
4558 free_netdev(dev1); 4561 hw->ports = 1;
4559 } else 4562 if (dev1)
4560 sky2_show_addr(dev1); 4563 free_netdev(dev1);
4564 }
4561 } 4565 }
4562 4566
4563 setup_timer(&hw->watchdog_timer, sky2_watchdog, (unsigned long) hw); 4567 setup_timer(&hw->watchdog_timer, sky2_watchdog, (unsigned long) hw);
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index 784b631cfa3c..3911be7c0cba 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -83,34 +83,6 @@ static inline void SMC_outw(u16 val, void __iomem *ioaddr, int reg)
83 } 83 }
84} 84}
85 85
86#elif defined(CONFIG_BLACKFIN)
87
88#define SMC_IRQ_FLAGS IRQF_TRIGGER_HIGH
89#define RPC_LSA_DEFAULT RPC_LED_100_10
90#define RPC_LSB_DEFAULT RPC_LED_TX_RX
91
92#define SMC_CAN_USE_8BIT 0
93#define SMC_CAN_USE_16BIT 1
94# if defined(CONFIG_BF561)
95#define SMC_CAN_USE_32BIT 1
96# else
97#define SMC_CAN_USE_32BIT 0
98# endif
99#define SMC_IO_SHIFT 0
100#define SMC_NOWAIT 1
101#define SMC_USE_BFIN_DMA 0
102
103#define SMC_inw(a, r) readw((a) + (r))
104#define SMC_outw(v, a, r) writew(v, (a) + (r))
105#define SMC_insw(a, r, p, l) readsw((a) + (r), p, l)
106#define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l)
107# if SMC_CAN_USE_32BIT
108#define SMC_inl(a, r) readl((a) + (r))
109#define SMC_outl(v, a, r) writel(v, (a) + (r))
110#define SMC_insl(a, r, p, l) readsl((a) + (r), p, l)
111#define SMC_outsl(a, r, p, l) writesl((a) + (r), p, l)
112# endif
113
114#elif defined(CONFIG_REDWOOD_5) || defined(CONFIG_REDWOOD_6) 86#elif defined(CONFIG_REDWOOD_5) || defined(CONFIG_REDWOOD_6)
115 87
116/* We can only do 16-bit reads and writes in the static memory space. */ 88/* We can only do 16-bit reads and writes in the static memory space. */
diff --git a/drivers/net/usb/cdc-phonet.c b/drivers/net/usb/cdc-phonet.c
index 97e54d9d03ce..33d5c579c5ad 100644
--- a/drivers/net/usb/cdc-phonet.c
+++ b/drivers/net/usb/cdc-phonet.c
@@ -264,7 +264,6 @@ static int usbpn_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
264 switch (cmd) { 264 switch (cmd) {
265 case SIOCPNGAUTOCONF: 265 case SIOCPNGAUTOCONF:
266 req->ifr_phonet_autoconf.device = PN_DEV_PC; 266 req->ifr_phonet_autoconf.device = PN_DEV_PC;
267 printk(KERN_CRIT"device is PN_DEV_PC\n");
268 return 0; 267 return 0;
269 } 268 }
270 return -ENOIOCTLCMD; 269 return -ENOIOCTLCMD;
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index ad89d23968df..49ea9c92b7e6 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -5,6 +5,7 @@
5menuconfig WLAN 5menuconfig WLAN
6 bool "Wireless LAN" 6 bool "Wireless LAN"
7 depends on !S390 7 depends on !S390
8 default y
8 ---help--- 9 ---help---
9 This section contains all the pre 802.11 and 802.11 wireless 10 This section contains all the pre 802.11 and 802.11 wireless
10 device drivers. For a complete list of drivers and documentation 11 device drivers. For a complete list of drivers and documentation
diff --git a/drivers/net/wireless/ath/ath9k/ani.c b/drivers/net/wireless/ath/ath9k/ani.c
index a7cbb07988cf..2b493742ef10 100644
--- a/drivers/net/wireless/ath/ath9k/ani.c
+++ b/drivers/net/wireless/ath/ath9k/ani.c
@@ -327,7 +327,8 @@ static void ath9k_hw_ani_ofdm_err_trigger(struct ath_hw *ah)
327 aniState->firstepLevel + 1); 327 aniState->firstepLevel + 1);
328 return; 328 return;
329 } else { 329 } else {
330 if (conf->channel->band == IEEE80211_BAND_2GHZ) { 330 if ((conf->channel->band == IEEE80211_BAND_2GHZ) &&
331 !conf_is_ht(conf)) {
331 if (!aniState->ofdmWeakSigDetectOff) 332 if (!aniState->ofdmWeakSigDetectOff)
332 ath9k_hw_ani_control(ah, 333 ath9k_hw_ani_control(ah,
333 ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION, 334 ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
@@ -369,7 +370,8 @@ static void ath9k_hw_ani_cck_err_trigger(struct ath_hw *ah)
369 ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL, 370 ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
370 aniState->firstepLevel + 1); 371 aniState->firstepLevel + 1);
371 } else { 372 } else {
372 if (conf->channel->band == IEEE80211_BAND_2GHZ) { 373 if ((conf->channel->band == IEEE80211_BAND_2GHZ) &&
374 !conf_is_ht(conf)) {
373 if (aniState->firstepLevel > 0) 375 if (aniState->firstepLevel > 0)
374 ath9k_hw_ani_control(ah, 376 ath9k_hw_ani_control(ah,
375 ATH9K_ANI_FIRSTEP_LEVEL, 0); 377 ATH9K_ANI_FIRSTEP_LEVEL, 0);
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 7a9a3fa55425..e789792a36bc 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -2289,11 +2289,7 @@ static int b43_upload_microcode(struct b43_wldev *dev)
2289 err = -ENODEV; 2289 err = -ENODEV;
2290 goto error; 2290 goto error;
2291 } 2291 }
2292 msleep_interruptible(50); 2292 msleep(50);
2293 if (signal_pending(current)) {
2294 err = -EINTR;
2295 goto error;
2296 }
2297 } 2293 }
2298 b43_read32(dev, B43_MMIO_GEN_IRQ_REASON); /* dummy read */ 2294 b43_read32(dev, B43_MMIO_GEN_IRQ_REASON); /* dummy read */
2299 2295
@@ -4287,6 +4283,8 @@ static int b43_wireless_core_init(struct b43_wldev *dev)
4287 if (!dev->suspend_in_progress) 4283 if (!dev->suspend_in_progress)
4288 b43_rng_init(wl); 4284 b43_rng_init(wl);
4289 4285
4286 ieee80211_wake_queues(dev->wl->hw);
4287
4290 b43_set_status(dev, B43_STAT_INITIALIZED); 4288 b43_set_status(dev, B43_STAT_INITIALIZED);
4291 4289
4292 if (!dev->suspend_in_progress) 4290 if (!dev->suspend_in_progress)
diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c
index 6fe122f18c0d..eb57d1ea361f 100644
--- a/drivers/net/wireless/hostap/hostap_main.c
+++ b/drivers/net/wireless/hostap/hostap_main.c
@@ -875,15 +875,16 @@ void hostap_setup_dev(struct net_device *dev, local_info_t *local,
875 875
876 switch(type) { 876 switch(type) {
877 case HOSTAP_INTERFACE_AP: 877 case HOSTAP_INTERFACE_AP:
878 dev->tx_queue_len = 0; /* use main radio device queue */
878 dev->netdev_ops = &hostap_mgmt_netdev_ops; 879 dev->netdev_ops = &hostap_mgmt_netdev_ops;
879 dev->type = ARPHRD_IEEE80211; 880 dev->type = ARPHRD_IEEE80211;
880 dev->header_ops = &hostap_80211_ops; 881 dev->header_ops = &hostap_80211_ops;
881 break; 882 break;
882 case HOSTAP_INTERFACE_MASTER: 883 case HOSTAP_INTERFACE_MASTER:
883 dev->tx_queue_len = 0; /* use main radio device queue */
884 dev->netdev_ops = &hostap_master_ops; 884 dev->netdev_ops = &hostap_master_ops;
885 break; 885 break;
886 default: 886 default:
887 dev->tx_queue_len = 0; /* use main radio device queue */
887 dev->netdev_ops = &hostap_netdev_ops; 888 dev->netdev_ops = &hostap_netdev_ops;
888 } 889 }
889 890
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 6a13bfbc9d98..ca61d3796cef 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -2346,6 +2346,7 @@ struct iwl_cfg iwl4965_agn_cfg = {
2346 .mod_params = &iwl4965_mod_params, 2346 .mod_params = &iwl4965_mod_params,
2347 .use_isr_legacy = true, 2347 .use_isr_legacy = true,
2348 .ht_greenfield_support = false, 2348 .ht_greenfield_support = false,
2349 .broken_powersave = true,
2349}; 2350};
2350 2351
2351/* Module firmware */ 2352/* Module firmware */
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index 40b207aa8fef..346dc06fa7b7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -760,6 +760,7 @@ static u32 rs_get_lower_rate(struct iwl_lq_sta *lq_sta,
760 u16 high_low; 760 u16 high_low;
761 u8 switch_to_legacy = 0; 761 u8 switch_to_legacy = 0;
762 u8 is_green = lq_sta->is_green; 762 u8 is_green = lq_sta->is_green;
763 struct iwl_priv *priv = lq_sta->drv;
763 764
764 /* check if we need to switch from HT to legacy rates. 765 /* check if we need to switch from HT to legacy rates.
765 * assumption is that mandatory rates (1Mbps or 6Mbps) 766 * assumption is that mandatory rates (1Mbps or 6Mbps)
@@ -773,7 +774,8 @@ static u32 rs_get_lower_rate(struct iwl_lq_sta *lq_sta,
773 tbl->lq_type = LQ_G; 774 tbl->lq_type = LQ_G;
774 775
775 if (num_of_ant(tbl->ant_type) > 1) 776 if (num_of_ant(tbl->ant_type) > 1)
776 tbl->ant_type = ANT_A;/*FIXME:RS*/ 777 tbl->ant_type =
778 first_antenna(priv->hw_params.valid_tx_ant);
777 779
778 tbl->is_ht40 = 0; 780 tbl->is_ht40 = 0;
779 tbl->is_SGI = 0; 781 tbl->is_SGI = 0;
@@ -883,6 +885,12 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
883 mac_index &= RATE_MCS_CODE_MSK; /* Remove # of streams */ 885 mac_index &= RATE_MCS_CODE_MSK; /* Remove # of streams */
884 if (mac_index >= (IWL_RATE_9M_INDEX - IWL_FIRST_OFDM_RATE)) 886 if (mac_index >= (IWL_RATE_9M_INDEX - IWL_FIRST_OFDM_RATE))
885 mac_index++; 887 mac_index++;
888 /*
889 * mac80211 HT index is always zero-indexed; we need to move
890 * HT OFDM rates after CCK rates in 2.4 GHz band
891 */
892 if (priv->band == IEEE80211_BAND_2GHZ)
893 mac_index += IWL_FIRST_OFDM_RATE;
886 } 894 }
887 895
888 if ((mac_index < 0) || 896 if ((mac_index < 0) ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index acfd7b40afb8..fd26c0dc9c54 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -1585,9 +1585,12 @@ int iwl_setup_mac(struct iwl_priv *priv)
1585 hw->flags = IEEE80211_HW_SIGNAL_DBM | 1585 hw->flags = IEEE80211_HW_SIGNAL_DBM |
1586 IEEE80211_HW_NOISE_DBM | 1586 IEEE80211_HW_NOISE_DBM |
1587 IEEE80211_HW_AMPDU_AGGREGATION | 1587 IEEE80211_HW_AMPDU_AGGREGATION |
1588 IEEE80211_HW_SPECTRUM_MGMT | 1588 IEEE80211_HW_SPECTRUM_MGMT;
1589 IEEE80211_HW_SUPPORTS_PS | 1589
1590 IEEE80211_HW_SUPPORTS_DYNAMIC_PS; 1590 if (!priv->cfg->broken_powersave)
1591 hw->flags |= IEEE80211_HW_SUPPORTS_PS |
1592 IEEE80211_HW_SUPPORTS_DYNAMIC_PS;
1593
1591 hw->wiphy->interface_modes = 1594 hw->wiphy->interface_modes =
1592 BIT(NL80211_IFTYPE_STATION) | 1595 BIT(NL80211_IFTYPE_STATION) |
1593 BIT(NL80211_IFTYPE_ADHOC); 1596 BIT(NL80211_IFTYPE_ADHOC);
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index c04d2a270819..7ff9ffb2b702 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -252,6 +252,7 @@ struct iwl_cfg {
252 const u16 max_ll_items; 252 const u16 max_ll_items;
253 const bool shadow_ram_support; 253 const bool shadow_ram_support;
254 const bool ht_greenfield_support; 254 const bool ht_greenfield_support;
255 const bool broken_powersave;
255}; 256};
256 257
257/*************************** 258/***************************
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c
index 4ec6a8307cc6..60be976afff8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.c
+++ b/drivers/net/wireless/iwlwifi/iwl-power.c
@@ -292,8 +292,9 @@ int iwl_power_update_mode(struct iwl_priv *priv, bool force)
292 else 292 else
293 dtimper = 1; 293 dtimper = 1;
294 294
295 /* TT power setting overwrites everything */ 295 if (priv->cfg->broken_powersave)
296 if (tt->state >= IWL_TI_1) 296 iwl_power_sleep_cam_cmd(priv, &cmd);
297 else if (tt->state >= IWL_TI_1)
297 iwl_static_sleep_cmd(priv, &cmd, tt->tt_power_mode, dtimper); 298 iwl_static_sleep_cmd(priv, &cmd, tt->tt_power_mode, dtimper);
298 else if (!enabled) 299 else if (!enabled)
299 iwl_power_sleep_cam_cmd(priv, &cmd); 300 iwl_power_sleep_cam_cmd(priv, &cmd);
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index 8150c5c3a16b..b90adcb73b06 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -239,26 +239,22 @@ void iwl_rx_allocate(struct iwl_priv *priv, gfp_t priority)
239 struct iwl_rx_queue *rxq = &priv->rxq; 239 struct iwl_rx_queue *rxq = &priv->rxq;
240 struct list_head *element; 240 struct list_head *element;
241 struct iwl_rx_mem_buffer *rxb; 241 struct iwl_rx_mem_buffer *rxb;
242 struct sk_buff *skb;
242 unsigned long flags; 243 unsigned long flags;
243 244
244 while (1) { 245 while (1) {
245 spin_lock_irqsave(&rxq->lock, flags); 246 spin_lock_irqsave(&rxq->lock, flags);
246
247 if (list_empty(&rxq->rx_used)) { 247 if (list_empty(&rxq->rx_used)) {
248 spin_unlock_irqrestore(&rxq->lock, flags); 248 spin_unlock_irqrestore(&rxq->lock, flags);
249 return; 249 return;
250 } 250 }
251 element = rxq->rx_used.next;
252 rxb = list_entry(element, struct iwl_rx_mem_buffer, list);
253 list_del(element);
254
255 spin_unlock_irqrestore(&rxq->lock, flags); 251 spin_unlock_irqrestore(&rxq->lock, flags);
256 252
257 /* Alloc a new receive buffer */ 253 /* Alloc a new receive buffer */
258 rxb->skb = alloc_skb(priv->hw_params.rx_buf_size + 256, 254 skb = alloc_skb(priv->hw_params.rx_buf_size + 256,
259 priority); 255 priority);
260 256
261 if (!rxb->skb) { 257 if (!skb) {
262 IWL_CRIT(priv, "Can not allocate SKB buffers\n"); 258 IWL_CRIT(priv, "Can not allocate SKB buffers\n");
263 /* We don't reschedule replenish work here -- we will 259 /* We don't reschedule replenish work here -- we will
264 * call the restock method and if it still needs 260 * call the restock method and if it still needs
@@ -266,6 +262,20 @@ void iwl_rx_allocate(struct iwl_priv *priv, gfp_t priority)
266 break; 262 break;
267 } 263 }
268 264
265 spin_lock_irqsave(&rxq->lock, flags);
266
267 if (list_empty(&rxq->rx_used)) {
268 spin_unlock_irqrestore(&rxq->lock, flags);
269 dev_kfree_skb_any(skb);
270 return;
271 }
272 element = rxq->rx_used.next;
273 rxb = list_entry(element, struct iwl_rx_mem_buffer, list);
274 list_del(element);
275
276 spin_unlock_irqrestore(&rxq->lock, flags);
277
278 rxb->skb = skb;
269 /* Get physical address of RB/SKB */ 279 /* Get physical address of RB/SKB */
270 rxb->real_dma_addr = pci_map_single( 280 rxb->real_dma_addr = pci_map_single(
271 priv->pci_dev, 281 priv->pci_dev,
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 2238c9f2018c..090966837f3c 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -1134,6 +1134,7 @@ static void iwl3945_rx_allocate(struct iwl_priv *priv, gfp_t priority)
1134 struct iwl_rx_queue *rxq = &priv->rxq; 1134 struct iwl_rx_queue *rxq = &priv->rxq;
1135 struct list_head *element; 1135 struct list_head *element;
1136 struct iwl_rx_mem_buffer *rxb; 1136 struct iwl_rx_mem_buffer *rxb;
1137 struct sk_buff *skb;
1137 unsigned long flags; 1138 unsigned long flags;
1138 1139
1139 while (1) { 1140 while (1) {
@@ -1143,17 +1144,11 @@ static void iwl3945_rx_allocate(struct iwl_priv *priv, gfp_t priority)
1143 spin_unlock_irqrestore(&rxq->lock, flags); 1144 spin_unlock_irqrestore(&rxq->lock, flags);
1144 return; 1145 return;
1145 } 1146 }
1146
1147 element = rxq->rx_used.next;
1148 rxb = list_entry(element, struct iwl_rx_mem_buffer, list);
1149 list_del(element);
1150 spin_unlock_irqrestore(&rxq->lock, flags); 1147 spin_unlock_irqrestore(&rxq->lock, flags);
1151 1148
1152 /* Alloc a new receive buffer */ 1149 /* Alloc a new receive buffer */
1153 rxb->skb = 1150 skb = alloc_skb(priv->hw_params.rx_buf_size, priority);
1154 alloc_skb(priv->hw_params.rx_buf_size, 1151 if (!skb) {
1155 priority);
1156 if (!rxb->skb) {
1157 if (net_ratelimit()) 1152 if (net_ratelimit())
1158 IWL_CRIT(priv, ": Can not allocate SKB buffers\n"); 1153 IWL_CRIT(priv, ": Can not allocate SKB buffers\n");
1159 /* We don't reschedule replenish work here -- we will 1154 /* We don't reschedule replenish work here -- we will
@@ -1162,6 +1157,19 @@ static void iwl3945_rx_allocate(struct iwl_priv *priv, gfp_t priority)
1162 break; 1157 break;
1163 } 1158 }
1164 1159
1160 spin_lock_irqsave(&rxq->lock, flags);
1161 if (list_empty(&rxq->rx_used)) {
1162 spin_unlock_irqrestore(&rxq->lock, flags);
1163 dev_kfree_skb_any(skb);
1164 return;
1165 }
1166 element = rxq->rx_used.next;
1167 rxb = list_entry(element, struct iwl_rx_mem_buffer, list);
1168 list_del(element);
1169 spin_unlock_irqrestore(&rxq->lock, flags);
1170
1171 rxb->skb = skb;
1172
1165 /* If radiotap head is required, reserve some headroom here. 1173 /* If radiotap head is required, reserve some headroom here.
1166 * The physical head count is a variable rx_stats->phy_count. 1174 * The physical head count is a variable rx_stats->phy_count.
1167 * We reserve 4 bytes here. Plus these extra bytes, the 1175 * We reserve 4 bytes here. Plus these extra bytes, the
diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c
index e44460ff149c..17e199546eeb 100644
--- a/drivers/net/wireless/p54/p54usb.c
+++ b/drivers/net/wireless/p54/p54usb.c
@@ -67,6 +67,7 @@ static struct usb_device_id p54u_table[] __devinitdata = {
67 {USB_DEVICE(0x0bf8, 0x1009)}, /* FUJITSU E-5400 USB D1700*/ 67 {USB_DEVICE(0x0bf8, 0x1009)}, /* FUJITSU E-5400 USB D1700*/
68 {USB_DEVICE(0x0cde, 0x0006)}, /* Medion MD40900 */ 68 {USB_DEVICE(0x0cde, 0x0006)}, /* Medion MD40900 */
69 {USB_DEVICE(0x0cde, 0x0008)}, /* Sagem XG703A */ 69 {USB_DEVICE(0x0cde, 0x0008)}, /* Sagem XG703A */
70 {USB_DEVICE(0x0cde, 0x0015)}, /* Zcomax XG-705A */
70 {USB_DEVICE(0x0d8e, 0x3762)}, /* DLink DWL-G120 Cohiba */ 71 {USB_DEVICE(0x0d8e, 0x3762)}, /* DLink DWL-G120 Cohiba */
71 {USB_DEVICE(0x124a, 0x4025)}, /* IOGear GWU513 (GW3887IK chip) */ 72 {USB_DEVICE(0x124a, 0x4025)}, /* IOGear GWU513 (GW3887IK chip) */
72 {USB_DEVICE(0x1260, 0xee22)}, /* SMC 2862W-G version 2 */ 73 {USB_DEVICE(0x1260, 0xee22)}, /* SMC 2862W-G version 2 */
diff --git a/drivers/net/wireless/wl12xx/wl1271_main.c b/drivers/net/wireless/wl12xx/wl1271_main.c
index d9169b47ac42..27298b19d5bd 100644
--- a/drivers/net/wireless/wl12xx/wl1271_main.c
+++ b/drivers/net/wireless/wl12xx/wl1271_main.c
@@ -644,11 +644,10 @@ static int wl1271_op_config_interface(struct ieee80211_hw *hw,
644{ 644{
645 struct wl1271 *wl = hw->priv; 645 struct wl1271 *wl = hw->priv;
646 struct sk_buff *beacon; 646 struct sk_buff *beacon;
647 DECLARE_MAC_BUF(mac);
648 int ret; 647 int ret;
649 648
650 wl1271_debug(DEBUG_MAC80211, "mac80211 config_interface bssid %s", 649 wl1271_debug(DEBUG_MAC80211, "mac80211 config_interface bssid %pM",
651 print_mac(mac, conf->bssid)); 650 conf->bssid);
652 wl1271_dump_ascii(DEBUG_MAC80211, "ssid: ", conf->ssid, 651 wl1271_dump_ascii(DEBUG_MAC80211, "ssid: ", conf->ssid,
653 conf->ssid_len); 652 conf->ssid_len);
654 653
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 79c9c5f5cdba..ed4648b556c7 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -868,11 +868,11 @@ static struct pcmcia_device_id serial_ids[] = {
868 PCMCIA_DEVICE_PROD_ID12("PCMCIA ", "C336MX ", 0x99bcafe9, 0xaa25bcab), 868 PCMCIA_DEVICE_PROD_ID12("PCMCIA ", "C336MX ", 0x99bcafe9, 0xaa25bcab),
869 PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "PCMCIA Dual RS-232 Serial Port Card", 0xc4420b35, 0x92abc92f), 869 PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "PCMCIA Dual RS-232 Serial Port Card", 0xc4420b35, 0x92abc92f),
870 PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "Dual RS-232 Serial Port PC Card", 0xc4420b35, 0x031a380d), 870 PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "Dual RS-232 Serial Port PC Card", 0xc4420b35, 0x031a380d),
871 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "EN2218-LAN/MODEM", 0x281f1c5d, 0x570f348e, "PCMLM28.cis"), 871 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "EN2218-LAN/MODEM", 0x281f1c5d, 0x570f348e, "cis/PCMLM28.cis"),
872 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "UE2218-LAN/MODEM", 0x281f1c5d, 0x6fdcacee, "PCMLM28.cis"), 872 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "UE2218-LAN/MODEM", 0x281f1c5d, 0x6fdcacee, "cis/PCMLM28.cis"),
873 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "PCMLM28.cis"), 873 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "cis/PCMLM28.cis"),
874 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "Psion Dacom", "Gold Card V34 Ethernet GSM", 0xf5f025c2, 0x4ae85d35, "PCMLM28.cis"), 874 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "Psion Dacom", "Gold Card V34 Ethernet GSM", 0xf5f025c2, 0x4ae85d35, "cis/PCMLM28.cis"),
875 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "LINKSYS", "PCMLM28", 0xf7cb0b07, 0x66881874, "PCMLM28.cis"), 875 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "LINKSYS", "PCMLM28", 0xf7cb0b07, 0x66881874, "cis/PCMLM28.cis"),
876 PCMCIA_MFC_DEVICE_CIS_PROD_ID12(1, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "DP83903.cis"), 876 PCMCIA_MFC_DEVICE_CIS_PROD_ID12(1, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "DP83903.cis"),
877 PCMCIA_MFC_DEVICE_CIS_PROD_ID4(1, "NSC MF LAN/Modem", 0x58fc6056, "DP83903.cis"), 877 PCMCIA_MFC_DEVICE_CIS_PROD_ID4(1, "NSC MF LAN/Modem", 0x58fc6056, "DP83903.cis"),
878 PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x0556, "cis/3CCFEM556.cis"), 878 PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x0556, "cis/3CCFEM556.cis"),
@@ -883,10 +883,10 @@ static struct pcmcia_device_id serial_ids[] = {
883 PCMCIA_DEVICE_CIS_MANF_CARD(0x0192, 0x0710, "SW_7xx_SER.cis"), /* Sierra Wireless AC710/AC750 GPRS Network Adapter R1 */ 883 PCMCIA_DEVICE_CIS_MANF_CARD(0x0192, 0x0710, "SW_7xx_SER.cis"), /* Sierra Wireless AC710/AC750 GPRS Network Adapter R1 */
884 PCMCIA_DEVICE_CIS_MANF_CARD(0x0192, 0xa555, "SW_555_SER.cis"), /* Sierra Aircard 555 CDMA 1xrtt Modem -- pre update */ 884 PCMCIA_DEVICE_CIS_MANF_CARD(0x0192, 0xa555, "SW_555_SER.cis"), /* Sierra Aircard 555 CDMA 1xrtt Modem -- pre update */
885 PCMCIA_DEVICE_CIS_MANF_CARD(0x013f, 0xa555, "SW_555_SER.cis"), /* Sierra Aircard 555 CDMA 1xrtt Modem -- post update */ 885 PCMCIA_DEVICE_CIS_MANF_CARD(0x013f, 0xa555, "SW_555_SER.cis"), /* Sierra Aircard 555 CDMA 1xrtt Modem -- post update */
886 PCMCIA_DEVICE_CIS_PROD_ID12("MultiTech", "PCMCIA 56K DataFax", 0x842047ee, 0xc2efcf03, "MT5634ZLX.cis"), 886 PCMCIA_DEVICE_CIS_PROD_ID12("MultiTech", "PCMCIA 56K DataFax", 0x842047ee, 0xc2efcf03, "cis/MT5634ZLX.cis"),
887 PCMCIA_DEVICE_CIS_PROD_ID12("ADVANTECH", "COMpad-32/85B-4", 0x96913a85, 0xcec8f102, "COMpad4.cis"), 887 PCMCIA_DEVICE_CIS_PROD_ID12("ADVANTECH", "COMpad-32/85B-4", 0x96913a85, 0xcec8f102, "COMpad4.cis"),
888 PCMCIA_DEVICE_CIS_PROD_ID123("ADVANTECH", "COMpad-32/85", "1.0", 0x96913a85, 0x8fbe92ae, 0x0877b627, "COMpad2.cis"), 888 PCMCIA_DEVICE_CIS_PROD_ID123("ADVANTECH", "COMpad-32/85", "1.0", 0x96913a85, 0x8fbe92ae, 0x0877b627, "COMpad2.cis"),
889 PCMCIA_DEVICE_CIS_PROD_ID2("RS-COM 2P", 0xad20b156, "RS-COM-2P.cis"), 889 PCMCIA_DEVICE_CIS_PROD_ID2("RS-COM 2P", 0xad20b156, "cis/RS-COM-2P.cis"),
890 PCMCIA_DEVICE_CIS_MANF_CARD(0x0013, 0x0000, "GLOBETROTTER.cis"), 890 PCMCIA_DEVICE_CIS_MANF_CARD(0x0013, 0x0000, "GLOBETROTTER.cis"),
891 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.","SERIAL CARD: SL100 1.00.",0x19ca78af,0xf964f42b), 891 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.","SERIAL CARD: SL100 1.00.",0x19ca78af,0xf964f42b),
892 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.","SERIAL CARD: SL100",0x19ca78af,0x71d98e83), 892 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.","SERIAL CARD: SL100",0x19ca78af,0x71d98e83),
diff --git a/drivers/ssb/pci.c b/drivers/ssb/pci.c
index f853d5600ca7..9e50896233aa 100644
--- a/drivers/ssb/pci.c
+++ b/drivers/ssb/pci.c
@@ -600,6 +600,7 @@ static int sprom_extract(struct ssb_bus *bus, struct ssb_sprom *out,
600 ssb_printk(KERN_WARNING PFX "Unsupported SPROM" 600 ssb_printk(KERN_WARNING PFX "Unsupported SPROM"
601 " revision %d detected. Will extract" 601 " revision %d detected. Will extract"
602 " v1\n", out->revision); 602 " v1\n", out->revision);
603 out->revision = 1;
603 sprom_extract_r123(out, in); 604 sprom_extract_r123(out, in);
604 } 605 }
605 } 606 }
diff --git a/drivers/ssb/sdio.c b/drivers/ssb/sdio.c
index 114051056b52..65a6080cb02a 100644
--- a/drivers/ssb/sdio.c
+++ b/drivers/ssb/sdio.c
@@ -21,7 +21,7 @@
21#include "ssb_private.h" 21#include "ssb_private.h"
22 22
23/* Define the following to 1 to enable a printk on each coreswitch. */ 23/* Define the following to 1 to enable a printk on each coreswitch. */
24#define SSB_VERBOSE_SDIOCORESWITCH_DEBUG 1 24#define SSB_VERBOSE_SDIOCORESWITCH_DEBUG 0
25 25
26 26
27/* Hardware invariants CIS tuples */ 27/* Hardware invariants CIS tuples */
@@ -333,7 +333,7 @@ static void ssb_sdio_block_read(struct ssb_device *dev, void *buffer,
333 goto out; 333 goto out;
334 334
335err_out: 335err_out:
336 dev_dbg(ssb_sdio_dev(bus), "%04X:%04X (width=%u, len=%u), error %d\n", 336 dev_dbg(ssb_sdio_dev(bus), "%04X:%04X (width=%u, len=%zu), error %d\n",
337 bus->sdio_sbaddr >> 16, offset, reg_width, saved_count, error); 337 bus->sdio_sbaddr >> 16, offset, reg_width, saved_count, error);
338out: 338out:
339 sdio_release_host(bus->host_sdio); 339 sdio_release_host(bus->host_sdio);
@@ -440,7 +440,7 @@ static void ssb_sdio_block_write(struct ssb_device *dev, const void *buffer,
440 goto out; 440 goto out;
441 441
442err_out: 442err_out:
443 dev_dbg(ssb_sdio_dev(bus), "%04X:%04X (width=%u, len=%u), error %d\n", 443 dev_dbg(ssb_sdio_dev(bus), "%04X:%04X (width=%u, len=%zu), error %d\n",
444 bus->sdio_sbaddr >> 16, offset, reg_width, saved_count, error); 444 bus->sdio_sbaddr >> 16, offset, reg_width, saved_count, error);
445out: 445out:
446 sdio_release_host(bus->host_sdio); 446 sdio_release_host(bus->host_sdio);
diff --git a/firmware/Makefile b/firmware/Makefile
index 878329cf4825..ffe2663d49f2 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -51,9 +51,10 @@ fw-shipped-$(CONFIG_DVB_TTUSB_BUDGET) += ttusb-budget/dspbootcode.bin
51fw-shipped-$(CONFIG_E100) += e100/d101m_ucode.bin e100/d101s_ucode.bin \ 51fw-shipped-$(CONFIG_E100) += e100/d101m_ucode.bin e100/d101s_ucode.bin \
52 e100/d102e_ucode.bin 52 e100/d102e_ucode.bin
53fw-shipped-$(CONFIG_MYRI_SBUS) += myricom/lanai.bin 53fw-shipped-$(CONFIG_MYRI_SBUS) += myricom/lanai.bin
54fw-shipped-$(CONFIG_PCMCIA_PCNET) += cis/LA-PCM.cis 54fw-shipped-$(CONFIG_PCMCIA_PCNET) += cis/LA-PCM.cis cis/PCMLM28.cis
55fw-shipped-$(CONFIG_PCMCIA_3C589) += cis/3CXEM556.cis 55fw-shipped-$(CONFIG_PCMCIA_3C589) += cis/3CXEM556.cis
56fw-shipped-$(CONFIG_PCMCIA_3C574) += cis/3CCFEM556.cis 56fw-shipped-$(CONFIG_PCMCIA_3C574) += cis/3CCFEM556.cis
57fw-shipped-$(CONFIG_SERIAL_8250_CS) += cis/MT5634ZLX.cis cis/RS-COM-2P.cis
57fw-shipped-$(CONFIG_PCMCIA_SMC91C92) += ositech/Xilinx7OD.bin 58fw-shipped-$(CONFIG_PCMCIA_SMC91C92) += ositech/Xilinx7OD.bin
58fw-shipped-$(CONFIG_SCSI_ADVANSYS) += advansys/mcode.bin advansys/38C1600.bin \ 59fw-shipped-$(CONFIG_SCSI_ADVANSYS) += advansys/mcode.bin advansys/38C1600.bin \
59 advansys/3550.bin advansys/38C0800.bin 60 advansys/3550.bin advansys/38C0800.bin
diff --git a/firmware/WHENCE b/firmware/WHENCE
index d9e3a94cb4df..82db5256a4e5 100644
--- a/firmware/WHENCE
+++ b/firmware/WHENCE
@@ -596,6 +596,7 @@ Found in hex form in kernel source.
596Driver: PCMCIA_PCNET - NE2000 compatible PCMCIA adapter 596Driver: PCMCIA_PCNET - NE2000 compatible PCMCIA adapter
597 597
598File: cis/LA-PCM.cis 598File: cis/LA-PCM.cis
599 cis/PCMLM28.cis
599 600
600Licence: GPL 601Licence: GPL
601 602
@@ -623,6 +624,17 @@ Originally developed by the pcmcia-cs project
623 624
624-------------------------------------------------------------------------- 625--------------------------------------------------------------------------
625 626
627Driver: SERIAL_8250_CS - Serial PCMCIA adapter
628
629File: cis/MT5634ZLX.cis
630 cis/RS-COM-2P.cis
631
632Licence: GPL
633
634Originally developed by the pcmcia-cs project
635
636--------------------------------------------------------------------------
637
626Driver: PCMCIA_SMC91C92 - SMC 91Cxx PCMCIA 638Driver: PCMCIA_SMC91C92 - SMC 91Cxx PCMCIA
627 639
628File: ositech/Xilinx7OD.bin 640File: ositech/Xilinx7OD.bin
diff --git a/firmware/cis/MT5634ZLX.cis.ihex b/firmware/cis/MT5634ZLX.cis.ihex
new file mode 100644
index 000000000000..72500b9d95d8
--- /dev/null
+++ b/firmware/cis/MT5634ZLX.cis.ihex
@@ -0,0 +1,11 @@
1:100000000101FF152204014D756C74695465636824
2:100010000050434D4349412035364B2044617461C3
3:10002000466178000000FF20040002010021020266
4:10003000001A05012780FF671B0FCF418B01550177
5:10004000550155AA60F80307281B08970108AA6004
6:10005000F802071B089F0108AA60E803071B08A70E
7:0B0060000108AA60E802071400FF007E
8:00000001FF
9#
10# Replacement CIS for Multitech MT5634ZLX modems
11#
diff --git a/firmware/cis/PCMLM28.cis.ihex b/firmware/cis/PCMLM28.cis.ihex
new file mode 100644
index 000000000000..ffdfe8522ef5
--- /dev/null
+++ b/firmware/cis/PCMLM28.cis.ihex
@@ -0,0 +1,18 @@
1:1000000001030000FF151504014C494E4B53595391
2:100010000050434D4C4D3238000000FF2004430196
3:10002000ABC0210200001A05012FF803031B10E4E6
4:1000300001190155E06100031FF8020730FFFF1BA3
5:100040000BA50108E06120031FF802071B0BA601A6
6:1000500008E06140031FF802071B0BA70108E061DD
7:1000600060031FF802071B0BA80108E06100031FD3
8:10007000E803071B0BA90108E06120031FE8030741
9:100080001B0BAA0108E06140031FE803071B0BAB31
10:100090000108E06160031FE803071B0BAC0108E0E7
11:1000A0006100031FE802071B0BAD0108E06120039C
12:1000B0001FE802071B0BAE0108E06140031FE802C6
13:1000C000071B0BAF0108E06160031FE80207140083
14:0200D000FF002F
15:00000001FF
16#
17# The on-card CIS says it is MFC-compliant, but it is not
18#
diff --git a/firmware/cis/RS-COM-2P.cis.ihex b/firmware/cis/RS-COM-2P.cis.ihex
new file mode 100644
index 000000000000..0801ca5da80a
--- /dev/null
+++ b/firmware/cis/RS-COM-2P.cis.ihex
@@ -0,0 +1,10 @@
1:1000000001030000FF1516040150434D4349410010
2:1000100052532D434F4D203250000000FF21020269
3:10002000011A0501030001011B0EC18118AA61E834
4:100030000307E8020730B89E1B0B820108AA615033
5:1000400002075802071B0B830108AA6160020768B8
6:0600500002071400FF008E
7:00000001FF
8#
9# Replacement CIS for dual-serial-port IO card
10#
diff --git a/include/keys/rxrpc-type.h b/include/keys/rxrpc-type.h
index 7609365577f1..5cb86c307f5d 100644
--- a/include/keys/rxrpc-type.h
+++ b/include/keys/rxrpc-type.h
@@ -21,4 +21,111 @@ extern struct key_type key_type_rxrpc;
21 21
22extern struct key *rxrpc_get_null_key(const char *); 22extern struct key *rxrpc_get_null_key(const char *);
23 23
24/*
25 * RxRPC key for Kerberos IV (type-2 security)
26 */
27struct rxkad_key {
28 u32 vice_id;
29 u32 start; /* time at which ticket starts */
30 u32 expiry; /* time at which ticket expires */
31 u32 kvno; /* key version number */
32 u8 primary_flag; /* T if key for primary cell for this user */
33 u16 ticket_len; /* length of ticket[] */
34 u8 session_key[8]; /* DES session key */
35 u8 ticket[0]; /* the encrypted ticket */
36};
37
38/*
39 * Kerberos 5 principal
40 * name/name/name@realm
41 */
42struct krb5_principal {
43 u8 n_name_parts; /* N of parts of the name part of the principal */
44 char **name_parts; /* parts of the name part of the principal */
45 char *realm; /* parts of the realm part of the principal */
46};
47
48/*
49 * Kerberos 5 tagged data
50 */
51struct krb5_tagged_data {
52 /* for tag value, see /usr/include/krb5/krb5.h
53 * - KRB5_AUTHDATA_* for auth data
54 * -
55 */
56 s32 tag;
57 u32 data_len;
58 u8 *data;
59};
60
61/*
62 * RxRPC key for Kerberos V (type-5 security)
63 */
64struct rxk5_key {
65 u64 authtime; /* time at which auth token generated */
66 u64 starttime; /* time at which auth token starts */
67 u64 endtime; /* time at which auth token expired */
68 u64 renew_till; /* time to which auth token can be renewed */
69 s32 is_skey; /* T if ticket is encrypted in another ticket's
70 * skey */
71 s32 flags; /* mask of TKT_FLG_* bits (krb5/krb5.h) */
72 struct krb5_principal client; /* client principal name */
73 struct krb5_principal server; /* server principal name */
74 u16 ticket_len; /* length of ticket */
75 u16 ticket2_len; /* length of second ticket */
76 u8 n_authdata; /* number of authorisation data elements */
77 u8 n_addresses; /* number of addresses */
78 struct krb5_tagged_data session; /* session data; tag is enctype */
79 struct krb5_tagged_data *addresses; /* addresses */
80 u8 *ticket; /* krb5 ticket */
81 u8 *ticket2; /* second krb5 ticket, if related to ticket (via
82 * DUPLICATE-SKEY or ENC-TKT-IN-SKEY) */
83 struct krb5_tagged_data *authdata; /* authorisation data */
84};
85
86/*
87 * list of tokens attached to an rxrpc key
88 */
89struct rxrpc_key_token {
90 u16 security_index; /* RxRPC header security index */
91 struct rxrpc_key_token *next; /* the next token in the list */
92 union {
93 struct rxkad_key *kad;
94 struct rxk5_key *k5;
95 };
96};
97
98/*
99 * structure of raw payloads passed to add_key() or instantiate key
100 */
101struct rxrpc_key_data_v1 {
102 u32 kif_version; /* 1 */
103 u16 security_index;
104 u16 ticket_length;
105 u32 expiry; /* time_t */
106 u32 kvno;
107 u8 session_key[8];
108 u8 ticket[0];
109};
110
111/*
112 * AF_RXRPC key payload derived from XDR format
113 * - based on openafs-1.4.10/src/auth/afs_token.xg
114 */
115#define AFSTOKEN_LENGTH_MAX 16384 /* max payload size */
116#define AFSTOKEN_STRING_MAX 256 /* max small string length */
117#define AFSTOKEN_DATA_MAX 64 /* max small data length */
118#define AFSTOKEN_CELL_MAX 64 /* max cellname length */
119#define AFSTOKEN_MAX 8 /* max tokens per payload */
120#define AFSTOKEN_BDATALN_MAX 16384 /* max big data length */
121#define AFSTOKEN_RK_TIX_MAX 12000 /* max RxKAD ticket size */
122#define AFSTOKEN_GK_KEY_MAX 64 /* max GSSAPI key size */
123#define AFSTOKEN_GK_TOKEN_MAX 16384 /* max GSSAPI token size */
124#define AFSTOKEN_K5_COMPONENTS_MAX 16 /* max K5 components */
125#define AFSTOKEN_K5_NAME_MAX 128 /* max K5 name length */
126#define AFSTOKEN_K5_REALM_MAX 64 /* max K5 realm name length */
127#define AFSTOKEN_K5_TIX_MAX 16384 /* max K5 ticket size */
128#define AFSTOKEN_K5_ADDRESSES_MAX 16 /* max K5 addresses */
129#define AFSTOKEN_K5_AUTHDATA_MAX 16 /* max K5 pieces of auth data */
130
24#endif /* _KEYS_RXRPC_TYPE_H */ 131#endif /* _KEYS_RXRPC_TYPE_H */
diff --git a/include/linux/igmp.h b/include/linux/igmp.h
index 92fbd8cbd68f..fe158e0e20e6 100644
--- a/include/linux/igmp.h
+++ b/include/linux/igmp.h
@@ -233,6 +233,8 @@ extern void ip_mc_init_dev(struct in_device *);
233extern void ip_mc_destroy_dev(struct in_device *); 233extern void ip_mc_destroy_dev(struct in_device *);
234extern void ip_mc_up(struct in_device *); 234extern void ip_mc_up(struct in_device *);
235extern void ip_mc_down(struct in_device *); 235extern void ip_mc_down(struct in_device *);
236extern void ip_mc_unmap(struct in_device *);
237extern void ip_mc_remap(struct in_device *);
236extern void ip_mc_dec_group(struct in_device *in_dev, __be32 addr); 238extern void ip_mc_dec_group(struct in_device *in_dev, __be32 addr);
237extern void ip_mc_inc_group(struct in_device *in_dev, __be32 addr); 239extern void ip_mc_inc_group(struct in_device *in_dev, __be32 addr);
238extern void ip_mc_rejoin_group(struct ip_mc_list *im); 240extern void ip_mc_rejoin_group(struct ip_mc_list *im);
diff --git a/include/linux/net.h b/include/linux/net.h
index 4fc2ffd527f9..9040a10584f7 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -57,6 +57,7 @@ typedef enum {
57#include <linux/random.h> 57#include <linux/random.h>
58#include <linux/wait.h> 58#include <linux/wait.h>
59#include <linux/fcntl.h> /* For O_CLOEXEC and O_NONBLOCK */ 59#include <linux/fcntl.h> /* For O_CLOEXEC and O_NONBLOCK */
60#include <linux/kmemcheck.h>
60 61
61struct poll_table_struct; 62struct poll_table_struct;
62struct pipe_inode_info; 63struct pipe_inode_info;
@@ -127,7 +128,11 @@ enum sock_shutdown_cmd {
127 */ 128 */
128struct socket { 129struct socket {
129 socket_state state; 130 socket_state state;
131
132 kmemcheck_bitfield_begin(type);
130 short type; 133 short type;
134 kmemcheck_bitfield_end(type);
135
131 unsigned long flags; 136 unsigned long flags;
132 /* 137 /*
133 * Please keep fasync_list & wait fields in the same cache line 138 * Please keep fasync_list & wait fields in the same cache line
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index a9aa4b5917d7..94958c109761 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1873,7 +1873,8 @@ extern void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, struct
1873extern int dev_set_promiscuity(struct net_device *dev, int inc); 1873extern int dev_set_promiscuity(struct net_device *dev, int inc);
1874extern int dev_set_allmulti(struct net_device *dev, int inc); 1874extern int dev_set_allmulti(struct net_device *dev, int inc);
1875extern void netdev_state_change(struct net_device *dev); 1875extern void netdev_state_change(struct net_device *dev);
1876extern void netdev_bonding_change(struct net_device *dev); 1876extern void netdev_bonding_change(struct net_device *dev,
1877 unsigned long event);
1877extern void netdev_features_change(struct net_device *dev); 1878extern void netdev_features_change(struct net_device *dev);
1878/* Load a device via the kmod */ 1879/* Load a device via the kmod */
1879extern void dev_load(struct net *net, const char *name); 1880extern void dev_load(struct net *net, const char *name);
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 0fbecbbe8e9e..080f6ba9e73a 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -176,12 +176,16 @@ struct netlink_skb_parms
176#define NETLINK_CREDS(skb) (&NETLINK_CB((skb)).creds) 176#define NETLINK_CREDS(skb) (&NETLINK_CB((skb)).creds)
177 177
178 178
179extern void netlink_table_grab(void);
180extern void netlink_table_ungrab(void);
181
179extern struct sock *netlink_kernel_create(struct net *net, 182extern struct sock *netlink_kernel_create(struct net *net,
180 int unit,unsigned int groups, 183 int unit,unsigned int groups,
181 void (*input)(struct sk_buff *skb), 184 void (*input)(struct sk_buff *skb),
182 struct mutex *cb_mutex, 185 struct mutex *cb_mutex,
183 struct module *module); 186 struct module *module);
184extern void netlink_kernel_release(struct sock *sk); 187extern void netlink_kernel_release(struct sock *sk);
188extern int __netlink_change_ngroups(struct sock *sk, unsigned int groups);
185extern int netlink_change_ngroups(struct sock *sk, unsigned int groups); 189extern int netlink_change_ngroups(struct sock *sk, unsigned int groups);
186extern void netlink_clear_multicast_users(struct sock *sk, unsigned int group); 190extern void netlink_clear_multicast_users(struct sock *sk, unsigned int group);
187extern void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err); 191extern void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err);
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index 81bc252dc8ac..44428d247dbe 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -199,6 +199,8 @@ static inline int notifier_to_errno(int ret)
199#define NETDEV_FEAT_CHANGE 0x000B 199#define NETDEV_FEAT_CHANGE 0x000B
200#define NETDEV_BONDING_FAILOVER 0x000C 200#define NETDEV_BONDING_FAILOVER 0x000C
201#define NETDEV_PRE_UP 0x000D 201#define NETDEV_PRE_UP 0x000D
202#define NETDEV_BONDING_OLDTYPE 0x000E
203#define NETDEV_BONDING_NEWTYPE 0x000F
202 204
203#define SYS_DOWN 0x0001 /* Notify of system down */ 205#define SYS_DOWN 0x0001 /* Notify of system down */
204#define SYS_RESTART SYS_DOWN 206#define SYS_RESTART SYS_DOWN
diff --git a/include/linux/rxrpc.h b/include/linux/rxrpc.h
index f7b826b565c7..a53915cd5581 100644
--- a/include/linux/rxrpc.h
+++ b/include/linux/rxrpc.h
@@ -58,5 +58,12 @@ struct sockaddr_rxrpc {
58#define RXRPC_SECURITY_AUTH 1 /* authenticated packets */ 58#define RXRPC_SECURITY_AUTH 1 /* authenticated packets */
59#define RXRPC_SECURITY_ENCRYPT 2 /* encrypted packets */ 59#define RXRPC_SECURITY_ENCRYPT 2 /* encrypted packets */
60 60
61/*
62 * RxRPC security indices
63 */
64#define RXRPC_SECURITY_NONE 0 /* no security protocol */
65#define RXRPC_SECURITY_RXKAD 2 /* kaserver or kerberos 4 */
66#define RXRPC_SECURITY_RXGK 4 /* gssapi-based */
67#define RXRPC_SECURITY_RXK5 5 /* kerberos 5 */
61 68
62#endif /* _LINUX_RXRPC_H */ 69#endif /* _LINUX_RXRPC_H */
diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index 7b55ab215a64..0f7c37825fc1 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -143,6 +143,8 @@ extern int __ipv6_dev_mc_dec(struct inet6_dev *idev, const struct in6_addr *addr
143extern int ipv6_dev_mc_dec(struct net_device *dev, const struct in6_addr *addr); 143extern int ipv6_dev_mc_dec(struct net_device *dev, const struct in6_addr *addr);
144extern void ipv6_mc_up(struct inet6_dev *idev); 144extern void ipv6_mc_up(struct inet6_dev *idev);
145extern void ipv6_mc_down(struct inet6_dev *idev); 145extern void ipv6_mc_down(struct inet6_dev *idev);
146extern void ipv6_mc_unmap(struct inet6_dev *idev);
147extern void ipv6_mc_remap(struct inet6_dev *idev);
146extern void ipv6_mc_init_dev(struct inet6_dev *idev); 148extern void ipv6_mc_init_dev(struct inet6_dev *idev);
147extern void ipv6_mc_destroy_dev(struct inet6_dev *idev); 149extern void ipv6_mc_destroy_dev(struct inet6_dev *idev);
148extern void addrconf_dad_failure(struct inet6_ifaddr *ifp); 150extern void addrconf_dad_failure(struct inet6_ifaddr *ifp);
diff --git a/include/net/protocol.h b/include/net/protocol.h
index 1089d5aabd49..60249e51b669 100644
--- a/include/net/protocol.h
+++ b/include/net/protocol.h
@@ -94,21 +94,20 @@ struct inet_protosw {
94#define INET_PROTOSW_PERMANENT 0x02 /* Permanent protocols are unremovable. */ 94#define INET_PROTOSW_PERMANENT 0x02 /* Permanent protocols are unremovable. */
95#define INET_PROTOSW_ICSK 0x04 /* Is this an inet_connection_sock? */ 95#define INET_PROTOSW_ICSK 0x04 /* Is this an inet_connection_sock? */
96 96
97extern struct net_protocol *inet_protocol_base; 97extern const struct net_protocol *inet_protos[MAX_INET_PROTOS];
98extern struct net_protocol *inet_protos[MAX_INET_PROTOS];
99 98
100#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) 99#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
101extern struct inet6_protocol *inet6_protos[MAX_INET_PROTOS]; 100extern const struct inet6_protocol *inet6_protos[MAX_INET_PROTOS];
102#endif 101#endif
103 102
104extern int inet_add_protocol(struct net_protocol *prot, unsigned char num); 103extern int inet_add_protocol(const struct net_protocol *prot, unsigned char num);
105extern int inet_del_protocol(struct net_protocol *prot, unsigned char num); 104extern int inet_del_protocol(const struct net_protocol *prot, unsigned char num);
106extern void inet_register_protosw(struct inet_protosw *p); 105extern void inet_register_protosw(struct inet_protosw *p);
107extern void inet_unregister_protosw(struct inet_protosw *p); 106extern void inet_unregister_protosw(struct inet_protosw *p);
108 107
109#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) 108#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
110extern int inet6_add_protocol(struct inet6_protocol *prot, unsigned char num); 109extern int inet6_add_protocol(const struct inet6_protocol *prot, unsigned char num);
111extern int inet6_del_protocol(struct inet6_protocol *prot, unsigned char num); 110extern int inet6_del_protocol(const struct inet6_protocol *prot, unsigned char num);
112extern int inet6_register_protosw(struct inet_protosw *p); 111extern int inet6_register_protosw(struct inet_protosw *p);
113extern void inet6_unregister_protosw(struct inet_protosw *p); 112extern void inet6_unregister_protosw(struct inet_protosw *p);
114#endif 113#endif
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 88eb9de095de..c33180dd42b4 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -81,7 +81,7 @@ struct Qdisc
81struct Qdisc_class_ops 81struct Qdisc_class_ops
82{ 82{
83 /* Child qdisc manipulation */ 83 /* Child qdisc manipulation */
84 unsigned int (*select_queue)(struct Qdisc *, struct tcmsg *); 84 struct netdev_queue * (*select_queue)(struct Qdisc *, struct tcmsg *);
85 int (*graft)(struct Qdisc *, unsigned long cl, 85 int (*graft)(struct Qdisc *, unsigned long cl,
86 struct Qdisc *, struct Qdisc **); 86 struct Qdisc *, struct Qdisc **);
87 struct Qdisc * (*leaf)(struct Qdisc *, unsigned long cl); 87 struct Qdisc * (*leaf)(struct Qdisc *, unsigned long cl);
diff --git a/include/net/tcp.h b/include/net/tcp.h
index b71a446d58f6..56b76027b85e 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -793,6 +793,13 @@ static inline unsigned int tcp_packets_in_flight(const struct tcp_sock *tp)
793 return tp->packets_out - tcp_left_out(tp) + tp->retrans_out; 793 return tp->packets_out - tcp_left_out(tp) + tp->retrans_out;
794} 794}
795 795
796#define TCP_INFINITE_SSTHRESH 0x7fffffff
797
798static inline bool tcp_in_initial_slowstart(const struct tcp_sock *tp)
799{
800 return tp->snd_ssthresh >= TCP_INFINITE_SSTHRESH;
801}
802
796/* If cwnd > ssthresh, we may raise ssthresh to be half-way to cwnd. 803/* If cwnd > ssthresh, we may raise ssthresh to be half-way to cwnd.
797 * The exception is rate halving phase, when cwnd is decreasing towards 804 * The exception is rate halving phase, when cwnd is decreasing towards
798 * ssthresh. 805 * ssthresh.
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index 4a6ff2ba4d07..b1a4290996b5 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -1372,7 +1372,7 @@ static int atalk_route_packet(struct sk_buff *skb, struct net_device *dev,
1372 1372
1373 if (aarp_send_ddp(rt->dev, skb, &ta, NULL) == NET_XMIT_DROP) 1373 if (aarp_send_ddp(rt->dev, skb, &ta, NULL) == NET_XMIT_DROP)
1374 return NET_RX_DROP; 1374 return NET_RX_DROP;
1375 return NET_XMIT_SUCCESS; 1375 return NET_RX_SUCCESS;
1376free_it: 1376free_it:
1377 kfree_skb(skb); 1377 kfree_skb(skb);
1378drop: 1378drop:
diff --git a/net/can/af_can.c b/net/can/af_can.c
index ef1c43a2ed56..606832115674 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -199,6 +199,8 @@ static int can_create(struct net *net, struct socket *sock, int protocol)
199 * @skb: pointer to socket buffer with CAN frame in data section 199 * @skb: pointer to socket buffer with CAN frame in data section
200 * @loop: loopback for listeners on local CAN sockets (recommended default!) 200 * @loop: loopback for listeners on local CAN sockets (recommended default!)
201 * 201 *
202 * Due to the loopback this routine must not be called from hardirq context.
203 *
202 * Return: 204 * Return:
203 * 0 on success 205 * 0 on success
204 * -ENETDOWN when the selected interface is down 206 * -ENETDOWN when the selected interface is down
@@ -278,7 +280,7 @@ int can_send(struct sk_buff *skb, int loop)
278 } 280 }
279 281
280 if (newskb) 282 if (newskb)
281 netif_rx(newskb); 283 netif_rx_ni(newskb);
282 284
283 /* update statistics */ 285 /* update statistics */
284 can_stats.tx_frames++; 286 can_stats.tx_frames++;
diff --git a/net/core/dev.c b/net/core/dev.c
index 84945470ab38..560c8c9c03ab 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1017,9 +1017,9 @@ void netdev_state_change(struct net_device *dev)
1017} 1017}
1018EXPORT_SYMBOL(netdev_state_change); 1018EXPORT_SYMBOL(netdev_state_change);
1019 1019
1020void netdev_bonding_change(struct net_device *dev) 1020void netdev_bonding_change(struct net_device *dev, unsigned long event)
1021{ 1021{
1022 call_netdevice_notifiers(NETDEV_BONDING_FAILOVER, dev); 1022 call_netdevice_notifiers(event, dev);
1023} 1023}
1024EXPORT_SYMBOL(netdev_bonding_change); 1024EXPORT_SYMBOL(netdev_bonding_change);
1025 1025
diff --git a/net/dccp/ccids/Kconfig b/net/dccp/ccids/Kconfig
index 4b5db44970aa..8408398cd44e 100644
--- a/net/dccp/ccids/Kconfig
+++ b/net/dccp/ccids/Kconfig
@@ -66,9 +66,9 @@ config IP_DCCP_CCID3_RTO
66 A value of 0 disables this feature by enforcing the value specified 66 A value of 0 disables this feature by enforcing the value specified
67 in RFC 3448. The following values have been suggested as bounds for 67 in RFC 3448. The following values have been suggested as bounds for
68 experimental use: 68 experimental use:
69 * 16-20ms to match the typical multimedia inter-frame interval 69 * 16-20ms to match the typical multimedia inter-frame interval
70 * 100ms as a reasonable compromise [default] 70 * 100ms as a reasonable compromise [default]
71 * 1000ms corresponds to the lower TCP RTO bound (RFC 2988, 2.4) 71 * 1000ms corresponds to the lower TCP RTO bound (RFC 2988, 2.4)
72 72
73 The default of 100ms is a compromise between a large value for 73 The default of 100ms is a compromise between a large value for
74 efficient DCCP implementations, and a small value to avoid disrupting 74 efficient DCCP implementations, and a small value to avoid disrupting
diff --git a/net/dccp/ccids/ccid2.c b/net/dccp/ccids/ccid2.c
index d235294ace23..e8cf99e880b0 100644
--- a/net/dccp/ccids/ccid2.c
+++ b/net/dccp/ccids/ccid2.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * net/dccp/ccids/ccid2.c
3 *
4 * Copyright (c) 2005, 2006 Andrea Bittau <a.bittau@cs.ucl.ac.uk> 2 * Copyright (c) 2005, 2006 Andrea Bittau <a.bittau@cs.ucl.ac.uk>
5 * 3 *
6 * Changes to meet Linux coding standards, and DCCP infrastructure fixes. 4 * Changes to meet Linux coding standards, and DCCP infrastructure fixes.
diff --git a/net/dccp/ccids/ccid2.h b/net/dccp/ccids/ccid2.h
index 2c94ca029010..326ac90fb909 100644
--- a/net/dccp/ccids/ccid2.h
+++ b/net/dccp/ccids/ccid2.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * net/dccp/ccids/ccid2.h
3 *
4 * Copyright (c) 2005 Andrea Bittau <a.bittau@cs.ucl.ac.uk> 2 * Copyright (c) 2005 Andrea Bittau <a.bittau@cs.ucl.ac.uk>
5 * 3 *
6 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
@@ -40,14 +38,14 @@ struct ccid2_seq {
40#define CCID2_SEQBUF_LEN 1024 38#define CCID2_SEQBUF_LEN 1024
41#define CCID2_SEQBUF_MAX 128 39#define CCID2_SEQBUF_MAX 128
42 40
43/** struct ccid2_hc_tx_sock - CCID2 TX half connection 41/**
44 * 42 * struct ccid2_hc_tx_sock - CCID2 TX half connection
45 * @ccid2hctx_{cwnd,ssthresh,pipe}: as per RFC 4341, section 5 43 * @ccid2hctx_{cwnd,ssthresh,pipe}: as per RFC 4341, section 5
46 * @ccid2hctx_packets_acked - Ack counter for deriving cwnd growth (RFC 3465) 44 * @ccid2hctx_packets_acked - Ack counter for deriving cwnd growth (RFC 3465)
47 * @ccid2hctx_lastrtt -time RTT was last measured 45 * @ccid2hctx_lastrtt -time RTT was last measured
48 * @ccid2hctx_rpseq - last consecutive seqno 46 * @ccid2hctx_rpseq - last consecutive seqno
49 * @ccid2hctx_rpdupack - dupacks since rpseq 47 * @ccid2hctx_rpdupack - dupacks since rpseq
50*/ 48 */
51struct ccid2_hc_tx_sock { 49struct ccid2_hc_tx_sock {
52 u32 ccid2hctx_cwnd; 50 u32 ccid2hctx_cwnd;
53 u32 ccid2hctx_ssthresh; 51 u32 ccid2hctx_ssthresh;
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index f596ce149c3c..34dcc798c457 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * net/dccp/ccids/ccid3.c
3 *
4 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK 2 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK
5 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. 3 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand.
6 * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz> 4 * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz>
@@ -750,7 +748,8 @@ static int ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb)
750 return 0; 748 return 0;
751} 749}
752 750
753/** ccid3_first_li - Implements [RFC 3448, 6.3.1] 751/**
752 * ccid3_first_li - Implements [RFC 5348, 6.3.1]
754 * 753 *
755 * Determine the length of the first loss interval via inverse lookup. 754 * Determine the length of the first loss interval via inverse lookup.
756 * Assume that X_recv can be computed by the throughput equation 755 * Assume that X_recv can be computed by the throughput equation
diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h
index 49ca32bd7e79..e5a244143846 100644
--- a/net/dccp/ccids/ccid3.h
+++ b/net/dccp/ccids/ccid3.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * net/dccp/ccids/ccid3.h
3 *
4 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. 2 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand.
5 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK 3 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK
6 * 4 *
@@ -75,8 +73,8 @@ enum ccid3_hc_tx_states {
75 TFRC_SSTATE_TERM, 73 TFRC_SSTATE_TERM,
76}; 74};
77 75
78/** struct ccid3_hc_tx_sock - CCID3 sender half-connection socket 76/**
79 * 77 * struct ccid3_hc_tx_sock - CCID3 sender half-connection socket
80 * @ccid3hctx_x - Current sending rate in 64 * bytes per second 78 * @ccid3hctx_x - Current sending rate in 64 * bytes per second
81 * @ccid3hctx_x_recv - Receive rate in 64 * bytes per second 79 * @ccid3hctx_x_recv - Receive rate in 64 * bytes per second
82 * @ccid3hctx_x_calc - Calculated rate in bytes per second 80 * @ccid3hctx_x_calc - Calculated rate in bytes per second
@@ -119,9 +117,9 @@ struct ccid3_hc_tx_sock {
119 117
120static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk) 118static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk)
121{ 119{
122 struct ccid3_hc_tx_sock *hctx = ccid_priv(dccp_sk(sk)->dccps_hc_tx_ccid); 120 struct ccid3_hc_tx_sock *hctx = ccid_priv(dccp_sk(sk)->dccps_hc_tx_ccid);
123 BUG_ON(hctx == NULL); 121 BUG_ON(hctx == NULL);
124 return hctx; 122 return hctx;
125} 123}
126 124
127/* TFRC receiver states */ 125/* TFRC receiver states */
@@ -131,22 +129,22 @@ enum ccid3_hc_rx_states {
131 TFRC_RSTATE_TERM = 127, 129 TFRC_RSTATE_TERM = 127,
132}; 130};
133 131
134/** struct ccid3_hc_rx_sock - CCID3 receiver half-connection socket 132/**
135 * 133 * struct ccid3_hc_rx_sock - CCID3 receiver half-connection socket
136 * @ccid3hcrx_x_recv - Receiver estimate of send rate (RFC 3448 4.3) 134 * @ccid3hcrx_x_recv - Receiver estimate of send rate (RFC 3448 4.3)
137 * @ccid3hcrx_rtt - Receiver estimate of rtt (non-standard) 135 * @ccid3hcrx_rtt - Receiver estimate of rtt (non-standard)
138 * @ccid3hcrx_p - Current loss event rate (RFC 3448 5.4) 136 * @ccid3hcrx_p - Current loss event rate (RFC 3448 5.4)
139 * @ccid3hcrx_last_counter - Tracks window counter (RFC 4342, 8.1) 137 * @ccid3hcrx_last_counter - Tracks window counter (RFC 4342, 8.1)
140 * @ccid3hcrx_state - Receiver state, one of %ccid3_hc_rx_states 138 * @ccid3hcrx_state - Receiver state, one of %ccid3_hc_rx_states
141 * @ccid3hcrx_bytes_recv - Total sum of DCCP payload bytes 139 * @ccid3hcrx_bytes_recv - Total sum of DCCP payload bytes
142 * @ccid3hcrx_x_recv - Receiver estimate of send rate (RFC 3448, sec. 4.3) 140 * @ccid3hcrx_x_recv - Receiver estimate of send rate (RFC 3448, sec. 4.3)
143 * @ccid3hcrx_rtt - Receiver estimate of RTT 141 * @ccid3hcrx_rtt - Receiver estimate of RTT
144 * @ccid3hcrx_tstamp_last_feedback - Time at which last feedback was sent 142 * @ccid3hcrx_tstamp_last_feedback - Time at which last feedback was sent
145 * @ccid3hcrx_tstamp_last_ack - Time at which last feedback was sent 143 * @ccid3hcrx_tstamp_last_ack - Time at which last feedback was sent
146 * @ccid3hcrx_hist - Packet history (loss detection + RTT sampling) 144 * @ccid3hcrx_hist - Packet history (loss detection + RTT sampling)
147 * @ccid3hcrx_li_hist - Loss Interval database 145 * @ccid3hcrx_li_hist - Loss Interval database
148 * @ccid3hcrx_s - Received packet size in bytes 146 * @ccid3hcrx_s - Received packet size in bytes
149 * @ccid3hcrx_pinv - Inverse of Loss Event Rate (RFC 4342, sec. 8.5) 147 * @ccid3hcrx_pinv - Inverse of Loss Event Rate (RFC 4342, sec. 8.5)
150 */ 148 */
151struct ccid3_hc_rx_sock { 149struct ccid3_hc_rx_sock {
152 u8 ccid3hcrx_last_counter:4; 150 u8 ccid3hcrx_last_counter:4;
@@ -163,9 +161,9 @@ struct ccid3_hc_rx_sock {
163 161
164static inline struct ccid3_hc_rx_sock *ccid3_hc_rx_sk(const struct sock *sk) 162static inline struct ccid3_hc_rx_sock *ccid3_hc_rx_sk(const struct sock *sk)
165{ 163{
166 struct ccid3_hc_rx_sock *hcrx = ccid_priv(dccp_sk(sk)->dccps_hc_rx_ccid); 164 struct ccid3_hc_rx_sock *hcrx = ccid_priv(dccp_sk(sk)->dccps_hc_rx_ccid);
167 BUG_ON(hcrx == NULL); 165 BUG_ON(hcrx == NULL);
168 return hcrx; 166 return hcrx;
169} 167}
170 168
171#endif /* _DCCP_CCID3_H_ */ 169#endif /* _DCCP_CCID3_H_ */
diff --git a/net/dccp/ccids/lib/loss_interval.c b/net/dccp/ccids/lib/loss_interval.c
index 4d1e40127264..8fc3cbf79071 100644
--- a/net/dccp/ccids/lib/loss_interval.c
+++ b/net/dccp/ccids/lib/loss_interval.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * net/dccp/ccids/lib/loss_interval.c
3 *
4 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK 2 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK
5 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. 3 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand.
6 * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz> 4 * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz>
@@ -21,7 +19,7 @@ static const int tfrc_lh_weights[NINTERVAL] = { 10, 10, 10, 10, 8, 6, 4, 2 };
21/* implements LIFO semantics on the array */ 19/* implements LIFO semantics on the array */
22static inline u8 LIH_INDEX(const u8 ctr) 20static inline u8 LIH_INDEX(const u8 ctr)
23{ 21{
24 return (LIH_SIZE - 1 - (ctr % LIH_SIZE)); 22 return LIH_SIZE - 1 - (ctr % LIH_SIZE);
25} 23}
26 24
27/* the `counter' index always points at the next entry to be populated */ 25/* the `counter' index always points at the next entry to be populated */
@@ -129,7 +127,8 @@ static inline u8 tfrc_lh_is_new_loss(struct tfrc_loss_interval *cur,
129 (cur->li_is_closed || SUB16(new_loss->tfrchrx_ccval, cur->li_ccval) > 4); 127 (cur->li_is_closed || SUB16(new_loss->tfrchrx_ccval, cur->li_ccval) > 4);
130} 128}
131 129
132/** tfrc_lh_interval_add - Insert new record into the Loss Interval database 130/**
131 * tfrc_lh_interval_add - Insert new record into the Loss Interval database
133 * @lh: Loss Interval database 132 * @lh: Loss Interval database
134 * @rh: Receive history containing a fresh loss event 133 * @rh: Receive history containing a fresh loss event
135 * @calc_first_li: Caller-dependent routine to compute length of first interval 134 * @calc_first_li: Caller-dependent routine to compute length of first interval
diff --git a/net/dccp/ccids/lib/loss_interval.h b/net/dccp/ccids/lib/loss_interval.h
index 246018a3b269..d1d2f5383b7d 100644
--- a/net/dccp/ccids/lib/loss_interval.h
+++ b/net/dccp/ccids/lib/loss_interval.h
@@ -1,8 +1,6 @@
1#ifndef _DCCP_LI_HIST_ 1#ifndef _DCCP_LI_HIST_
2#define _DCCP_LI_HIST_ 2#define _DCCP_LI_HIST_
3/* 3/*
4 * net/dccp/ccids/lib/loss_interval.h
5 *
6 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK 4 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK
7 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. 5 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand.
8 * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz> 6 * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz>
diff --git a/net/dccp/ccids/lib/packet_history.c b/net/dccp/ccids/lib/packet_history.c
index b7785b3581ec..3a4f414e94a0 100644
--- a/net/dccp/ccids/lib/packet_history.c
+++ b/net/dccp/ccids/lib/packet_history.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * net/dccp/packet_history.c
3 *
4 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK 2 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK
5 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. 3 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand.
6 * 4 *
@@ -128,7 +126,7 @@ u32 tfrc_tx_hist_rtt(struct tfrc_tx_hist_entry *head, const u64 seqno,
128 126
129 127
130/* 128/*
131 * Receiver History Routines 129 * Receiver History Routines
132 */ 130 */
133static struct kmem_cache *tfrc_rx_hist_slab; 131static struct kmem_cache *tfrc_rx_hist_slab;
134 132
diff --git a/net/dccp/ccids/lib/packet_history.h b/net/dccp/ccids/lib/packet_history.h
index 461cc91cce88..7df6c5299999 100644
--- a/net/dccp/ccids/lib/packet_history.h
+++ b/net/dccp/ccids/lib/packet_history.h
@@ -70,7 +70,6 @@ struct tfrc_rx_hist_entry {
70 70
71/** 71/**
72 * tfrc_rx_hist - RX history structure for TFRC-based protocols 72 * tfrc_rx_hist - RX history structure for TFRC-based protocols
73 *
74 * @ring: Packet history for RTT sampling and loss detection 73 * @ring: Packet history for RTT sampling and loss detection
75 * @loss_count: Number of entries in circular history 74 * @loss_count: Number of entries in circular history
76 * @loss_start: Movable index (for loss detection) 75 * @loss_start: Movable index (for loss detection)
diff --git a/net/dccp/ccids/lib/tfrc.h b/net/dccp/ccids/lib/tfrc.h
index e9720b143275..01bb48e96c2e 100644
--- a/net/dccp/ccids/lib/tfrc.h
+++ b/net/dccp/ccids/lib/tfrc.h
@@ -1,8 +1,6 @@
1#ifndef _TFRC_H_ 1#ifndef _TFRC_H_
2#define _TFRC_H_ 2#define _TFRC_H_
3/* 3/*
4 * net/dccp/ccids/lib/tfrc.h
5 *
6 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK 4 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK
7 * Copyright (c) 2005-6 The University of Waikato, Hamilton, New Zealand. 5 * Copyright (c) 2005-6 The University of Waikato, Hamilton, New Zealand.
8 * Copyright (c) 2005-6 Ian McDonald <ian.mcdonald@jandi.co.nz> 6 * Copyright (c) 2005-6 Ian McDonald <ian.mcdonald@jandi.co.nz>
@@ -32,7 +30,7 @@ extern int tfrc_debug;
32/* integer-arithmetic divisions of type (a * 1000000)/b */ 30/* integer-arithmetic divisions of type (a * 1000000)/b */
33static inline u64 scaled_div(u64 a, u64 b) 31static inline u64 scaled_div(u64 a, u64 b)
34{ 32{
35 BUG_ON(b==0); 33 BUG_ON(b == 0);
36 return div64_u64(a * 1000000, b); 34 return div64_u64(a * 1000000, b);
37} 35}
38 36
diff --git a/net/dccp/ccids/lib/tfrc_equation.c b/net/dccp/ccids/lib/tfrc_equation.c
index c5d3a9e5a5a4..22ca1cf0eb55 100644
--- a/net/dccp/ccids/lib/tfrc_equation.c
+++ b/net/dccp/ccids/lib/tfrc_equation.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * net/dccp/ccids/lib/tfrc_equation.c
3 *
4 * Copyright (c) 2005 The University of Waikato, Hamilton, New Zealand. 2 * Copyright (c) 2005 The University of Waikato, Hamilton, New Zealand.
5 * Copyright (c) 2005 Ian McDonald <ian.mcdonald@jandi.co.nz> 3 * Copyright (c) 2005 Ian McDonald <ian.mcdonald@jandi.co.nz>
6 * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@conectiva.com.br> 4 * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
@@ -79,10 +77,10 @@
79 } 77 }
80 78
81 With the given configuration, we have, with M = TFRC_CALC_X_ARRSIZE-1, 79 With the given configuration, we have, with M = TFRC_CALC_X_ARRSIZE-1,
82 lookup[0][0] = g(1000000/(M+1)) = 1000000 * f(0.2%) 80 lookup[0][0] = g(1000000/(M+1)) = 1000000 * f(0.2%)
83 lookup[M][0] = g(1000000) = 1000000 * f(100%) 81 lookup[M][0] = g(1000000) = 1000000 * f(100%)
84 lookup[0][1] = g(TFRC_SMALLEST_P) = 1000000 * f(0.01%) 82 lookup[0][1] = g(TFRC_SMALLEST_P) = 1000000 * f(0.01%)
85 lookup[M][1] = g(TFRC_CALC_X_SPLIT) = 1000000 * f(5%) 83 lookup[M][1] = g(TFRC_CALC_X_SPLIT) = 1000000 * f(5%)
86 84
87 In summary, the two columns represent f(p) for the following ranges: 85 In summary, the two columns represent f(p) for the following ranges:
88 * The first column is for 0.002 <= p <= 1.0 86 * The first column is for 0.002 <= p <= 1.0
@@ -610,11 +608,10 @@ static inline u32 tfrc_binsearch(u32 fval, u8 small)
610 608
611/** 609/**
612 * tfrc_calc_x - Calculate the send rate as per section 3.1 of RFC3448 610 * tfrc_calc_x - Calculate the send rate as per section 3.1 of RFC3448
613 * 611 * @s: packet size in bytes
614 * @s: packet size in bytes 612 * @R: RTT scaled by 1000000 (i.e., microseconds)
615 * @R: RTT scaled by 1000000 (i.e., microseconds) 613 * @p: loss ratio estimate scaled by 1000000
616 * @p: loss ratio estimate scaled by 1000000 614 * Returns X_calc in bytes per second (not scaled).
617 * Returns X_calc in bytes per second (not scaled).
618 */ 615 */
619u32 tfrc_calc_x(u16 s, u32 R, u32 p) 616u32 tfrc_calc_x(u16 s, u32 R, u32 p)
620{ 617{
@@ -630,17 +627,17 @@ u32 tfrc_calc_x(u16 s, u32 R, u32 p)
630 return ~0U; 627 return ~0U;
631 } 628 }
632 629
633 if (p <= TFRC_CALC_X_SPLIT) { /* 0.0000 < p <= 0.05 */ 630 if (p <= TFRC_CALC_X_SPLIT) { /* 0.0000 < p <= 0.05 */
634 if (p < TFRC_SMALLEST_P) { /* 0.0000 < p < 0.0001 */ 631 if (p < TFRC_SMALLEST_P) { /* 0.0000 < p < 0.0001 */
635 DCCP_WARN("Value of p (%d) below resolution. " 632 DCCP_WARN("Value of p (%d) below resolution. "
636 "Substituting %d\n", p, TFRC_SMALLEST_P); 633 "Substituting %d\n", p, TFRC_SMALLEST_P);
637 index = 0; 634 index = 0;
638 } else /* 0.0001 <= p <= 0.05 */ 635 } else /* 0.0001 <= p <= 0.05 */
639 index = p/TFRC_SMALLEST_P - 1; 636 index = p/TFRC_SMALLEST_P - 1;
640 637
641 f = tfrc_calc_x_lookup[index][1]; 638 f = tfrc_calc_x_lookup[index][1];
642 639
643 } else { /* 0.05 < p <= 1.00 */ 640 } else { /* 0.05 < p <= 1.00 */
644 index = p/(1000000/TFRC_CALC_X_ARRSIZE) - 1; 641 index = p/(1000000/TFRC_CALC_X_ARRSIZE) - 1;
645 642
646 f = tfrc_calc_x_lookup[index][0]; 643 f = tfrc_calc_x_lookup[index][0];
@@ -661,7 +658,6 @@ u32 tfrc_calc_x(u16 s, u32 R, u32 p)
661 658
662/** 659/**
663 * tfrc_calc_x_reverse_lookup - try to find p given f(p) 660 * tfrc_calc_x_reverse_lookup - try to find p given f(p)
664 *
665 * @fvalue: function value to match, scaled by 1000000 661 * @fvalue: function value to match, scaled by 1000000
666 * Returns closest match for p, also scaled by 1000000 662 * Returns closest match for p, also scaled by 1000000
667 */ 663 */
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index d01c00de1ad0..7302e1498d46 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -948,7 +948,7 @@ static struct proto dccp_v4_prot = {
948#endif 948#endif
949}; 949};
950 950
951static struct net_protocol dccp_v4_protocol = { 951static const struct net_protocol dccp_v4_protocol = {
952 .handler = dccp_v4_rcv, 952 .handler = dccp_v4_rcv,
953 .err_handler = dccp_v4_err, 953 .err_handler = dccp_v4_err,
954 .no_policy = 1, 954 .no_policy = 1,
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 64f011cc4491..e48ca5d45658 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -1152,13 +1152,13 @@ static struct proto dccp_v6_prot = {
1152#endif 1152#endif
1153}; 1153};
1154 1154
1155static struct inet6_protocol dccp_v6_protocol = { 1155static const struct inet6_protocol dccp_v6_protocol = {
1156 .handler = dccp_v6_rcv, 1156 .handler = dccp_v6_rcv,
1157 .err_handler = dccp_v6_err, 1157 .err_handler = dccp_v6_err,
1158 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL, 1158 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
1159}; 1159};
1160 1160
1161static struct proto_ops inet6_dccp_ops = { 1161static const struct proto_ops inet6_dccp_ops = {
1162 .family = PF_INET6, 1162 .family = PF_INET6,
1163 .owner = THIS_MODULE, 1163 .owner = THIS_MODULE,
1164 .release = inet6_release, 1164 .release = inet6_release,
diff --git a/net/ieee802154/dgram.c b/net/ieee802154/dgram.c
index 77ae6852b93d..51593a48f2dd 100644
--- a/net/ieee802154/dgram.c
+++ b/net/ieee802154/dgram.c
@@ -414,7 +414,7 @@ static int dgram_getsockopt(struct sock *sk, int level, int optname,
414} 414}
415 415
416static int dgram_setsockopt(struct sock *sk, int level, int optname, 416static int dgram_setsockopt(struct sock *sk, int level, int optname,
417 char __user *optval, int __user optlen) 417 char __user *optval, int optlen)
418{ 418{
419 struct dgram_sock *ro = dgram_sk(sk); 419 struct dgram_sock *ro = dgram_sk(sk);
420 int val; 420 int val;
diff --git a/net/ieee802154/netlink.c b/net/ieee802154/netlink.c
index 2106ecbf0308..ca767bde17a4 100644
--- a/net/ieee802154/netlink.c
+++ b/net/ieee802154/netlink.c
@@ -35,6 +35,7 @@
35#include <net/ieee802154_netdev.h> 35#include <net/ieee802154_netdev.h>
36 36
37static unsigned int ieee802154_seq_num; 37static unsigned int ieee802154_seq_num;
38static DEFINE_SPINLOCK(ieee802154_seq_lock);
38 39
39static struct genl_family ieee802154_coordinator_family = { 40static struct genl_family ieee802154_coordinator_family = {
40 .id = GENL_ID_GENERATE, 41 .id = GENL_ID_GENERATE,
@@ -57,12 +58,15 @@ static struct sk_buff *ieee802154_nl_create(int flags, u8 req)
57{ 58{
58 void *hdr; 59 void *hdr;
59 struct sk_buff *msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); 60 struct sk_buff *msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC);
61 unsigned long f;
60 62
61 if (!msg) 63 if (!msg)
62 return NULL; 64 return NULL;
63 65
66 spin_lock_irqsave(&ieee802154_seq_lock, f);
64 hdr = genlmsg_put(msg, 0, ieee802154_seq_num++, 67 hdr = genlmsg_put(msg, 0, ieee802154_seq_num++,
65 &ieee802154_coordinator_family, flags, req); 68 &ieee802154_coordinator_family, flags, req);
69 spin_unlock_irqrestore(&ieee802154_seq_lock, f);
66 if (!hdr) { 70 if (!hdr) {
67 nlmsg_free(msg); 71 nlmsg_free(msg);
68 return NULL; 72 return NULL;
diff --git a/net/ieee802154/raw.c b/net/ieee802154/raw.c
index 4681501aae93..13198859982e 100644
--- a/net/ieee802154/raw.c
+++ b/net/ieee802154/raw.c
@@ -244,7 +244,7 @@ static int raw_getsockopt(struct sock *sk, int level, int optname,
244} 244}
245 245
246static int raw_setsockopt(struct sock *sk, int level, int optname, 246static int raw_setsockopt(struct sock *sk, int level, int optname,
247 char __user *optval, int __user optlen) 247 char __user *optval, int optlen)
248{ 248{
249 return -EOPNOTSUPP; 249 return -EOPNOTSUPP;
250} 250}
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 6c30a73f03f5..58c4b0f7c4aa 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -244,7 +244,7 @@ EXPORT_SYMBOL(build_ehash_secret);
244static inline int inet_netns_ok(struct net *net, int protocol) 244static inline int inet_netns_ok(struct net *net, int protocol)
245{ 245{
246 int hash; 246 int hash;
247 struct net_protocol *ipprot; 247 const struct net_protocol *ipprot;
248 248
249 if (net_eq(net, &init_net)) 249 if (net_eq(net, &init_net))
250 return 1; 250 return 1;
@@ -1162,7 +1162,7 @@ EXPORT_SYMBOL(inet_sk_rebuild_header);
1162static int inet_gso_send_check(struct sk_buff *skb) 1162static int inet_gso_send_check(struct sk_buff *skb)
1163{ 1163{
1164 struct iphdr *iph; 1164 struct iphdr *iph;
1165 struct net_protocol *ops; 1165 const struct net_protocol *ops;
1166 int proto; 1166 int proto;
1167 int ihl; 1167 int ihl;
1168 int err = -EINVAL; 1168 int err = -EINVAL;
@@ -1198,7 +1198,7 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb, int features)
1198{ 1198{
1199 struct sk_buff *segs = ERR_PTR(-EINVAL); 1199 struct sk_buff *segs = ERR_PTR(-EINVAL);
1200 struct iphdr *iph; 1200 struct iphdr *iph;
1201 struct net_protocol *ops; 1201 const struct net_protocol *ops;
1202 int proto; 1202 int proto;
1203 int ihl; 1203 int ihl;
1204 int id; 1204 int id;
@@ -1265,7 +1265,7 @@ out:
1265static struct sk_buff **inet_gro_receive(struct sk_buff **head, 1265static struct sk_buff **inet_gro_receive(struct sk_buff **head,
1266 struct sk_buff *skb) 1266 struct sk_buff *skb)
1267{ 1267{
1268 struct net_protocol *ops; 1268 const struct net_protocol *ops;
1269 struct sk_buff **pp = NULL; 1269 struct sk_buff **pp = NULL;
1270 struct sk_buff *p; 1270 struct sk_buff *p;
1271 struct iphdr *iph; 1271 struct iphdr *iph;
@@ -1342,7 +1342,7 @@ out:
1342 1342
1343static int inet_gro_complete(struct sk_buff *skb) 1343static int inet_gro_complete(struct sk_buff *skb)
1344{ 1344{
1345 struct net_protocol *ops; 1345 const struct net_protocol *ops;
1346 struct iphdr *iph = ip_hdr(skb); 1346 struct iphdr *iph = ip_hdr(skb);
1347 int proto = iph->protocol & (MAX_INET_PROTOS - 1); 1347 int proto = iph->protocol & (MAX_INET_PROTOS - 1);
1348 int err = -ENOSYS; 1348 int err = -ENOSYS;
@@ -1427,13 +1427,13 @@ void snmp_mib_free(void *ptr[2])
1427EXPORT_SYMBOL_GPL(snmp_mib_free); 1427EXPORT_SYMBOL_GPL(snmp_mib_free);
1428 1428
1429#ifdef CONFIG_IP_MULTICAST 1429#ifdef CONFIG_IP_MULTICAST
1430static struct net_protocol igmp_protocol = { 1430static const struct net_protocol igmp_protocol = {
1431 .handler = igmp_rcv, 1431 .handler = igmp_rcv,
1432 .netns_ok = 1, 1432 .netns_ok = 1,
1433}; 1433};
1434#endif 1434#endif
1435 1435
1436static struct net_protocol tcp_protocol = { 1436static const struct net_protocol tcp_protocol = {
1437 .handler = tcp_v4_rcv, 1437 .handler = tcp_v4_rcv,
1438 .err_handler = tcp_v4_err, 1438 .err_handler = tcp_v4_err,
1439 .gso_send_check = tcp_v4_gso_send_check, 1439 .gso_send_check = tcp_v4_gso_send_check,
@@ -1444,7 +1444,7 @@ static struct net_protocol tcp_protocol = {
1444 .netns_ok = 1, 1444 .netns_ok = 1,
1445}; 1445};
1446 1446
1447static struct net_protocol udp_protocol = { 1447static const struct net_protocol udp_protocol = {
1448 .handler = udp_rcv, 1448 .handler = udp_rcv,
1449 .err_handler = udp_err, 1449 .err_handler = udp_err,
1450 .gso_send_check = udp4_ufo_send_check, 1450 .gso_send_check = udp4_ufo_send_check,
@@ -1453,7 +1453,7 @@ static struct net_protocol udp_protocol = {
1453 .netns_ok = 1, 1453 .netns_ok = 1,
1454}; 1454};
1455 1455
1456static struct net_protocol icmp_protocol = { 1456static const struct net_protocol icmp_protocol = {
1457 .handler = icmp_rcv, 1457 .handler = icmp_rcv,
1458 .no_policy = 1, 1458 .no_policy = 1,
1459 .netns_ok = 1, 1459 .netns_ok = 1,
diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
index e878e494296e..5c662703eb1e 100644
--- a/net/ipv4/ah4.c
+++ b/net/ipv4/ah4.c
@@ -311,7 +311,7 @@ static const struct xfrm_type ah_type =
311 .output = ah_output 311 .output = ah_output
312}; 312};
313 313
314static struct net_protocol ah4_protocol = { 314static const struct net_protocol ah4_protocol = {
315 .handler = xfrm4_rcv, 315 .handler = xfrm4_rcv,
316 .err_handler = ah4_err, 316 .err_handler = ah4_err,
317 .no_policy = 1, 317 .no_policy = 1,
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 3863c3a4223f..07336c6201f0 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1087,6 +1087,12 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
1087 case NETDEV_DOWN: 1087 case NETDEV_DOWN:
1088 ip_mc_down(in_dev); 1088 ip_mc_down(in_dev);
1089 break; 1089 break;
1090 case NETDEV_BONDING_OLDTYPE:
1091 ip_mc_unmap(in_dev);
1092 break;
1093 case NETDEV_BONDING_NEWTYPE:
1094 ip_mc_remap(in_dev);
1095 break;
1090 case NETDEV_CHANGEMTU: 1096 case NETDEV_CHANGEMTU:
1091 if (inetdev_valid_mtu(dev->mtu)) 1097 if (inetdev_valid_mtu(dev->mtu))
1092 break; 1098 break;
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index 18bb383ea393..12f7287e902d 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -615,7 +615,7 @@ static const struct xfrm_type esp_type =
615 .output = esp_output 615 .output = esp_output
616}; 616};
617 617
618static struct net_protocol esp4_protocol = { 618static const struct net_protocol esp4_protocol = {
619 .handler = xfrm4_rcv, 619 .handler = xfrm4_rcv,
620 .err_handler = esp4_err, 620 .err_handler = esp4_err,
621 .no_policy = 1, 621 .no_policy = 1,
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 97c410e84388..5bc13fe816d1 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -655,7 +655,7 @@ static void icmp_unreach(struct sk_buff *skb)
655 struct iphdr *iph; 655 struct iphdr *iph;
656 struct icmphdr *icmph; 656 struct icmphdr *icmph;
657 int hash, protocol; 657 int hash, protocol;
658 struct net_protocol *ipprot; 658 const struct net_protocol *ipprot;
659 u32 info = 0; 659 u32 info = 0;
660 struct net *net; 660 struct net *net;
661 661
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 01b4284ed694..d41e5de79a82 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1298,6 +1298,28 @@ void ip_mc_dec_group(struct in_device *in_dev, __be32 addr)
1298 } 1298 }
1299} 1299}
1300 1300
1301/* Device changing type */
1302
1303void ip_mc_unmap(struct in_device *in_dev)
1304{
1305 struct ip_mc_list *i;
1306
1307 ASSERT_RTNL();
1308
1309 for (i = in_dev->mc_list; i; i = i->next)
1310 igmp_group_dropped(i);
1311}
1312
1313void ip_mc_remap(struct in_device *in_dev)
1314{
1315 struct ip_mc_list *i;
1316
1317 ASSERT_RTNL();
1318
1319 for (i = in_dev->mc_list; i; i = i->next)
1320 igmp_group_added(i);
1321}
1322
1301/* Device going down */ 1323/* Device going down */
1302 1324
1303void ip_mc_down(struct in_device *in_dev) 1325void ip_mc_down(struct in_device *in_dev)
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 533afaadefd4..d9645c94a067 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -1288,7 +1288,7 @@ static void ipgre_fb_tunnel_init(struct net_device *dev)
1288} 1288}
1289 1289
1290 1290
1291static struct net_protocol ipgre_protocol = { 1291static const struct net_protocol ipgre_protocol = {
1292 .handler = ipgre_rcv, 1292 .handler = ipgre_rcv,
1293 .err_handler = ipgre_err, 1293 .err_handler = ipgre_err,
1294 .netns_ok = 1, 1294 .netns_ok = 1,
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index db46b4b5b2b9..6c98b43badf4 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -202,7 +202,7 @@ static int ip_local_deliver_finish(struct sk_buff *skb)
202 { 202 {
203 int protocol = ip_hdr(skb)->protocol; 203 int protocol = ip_hdr(skb)->protocol;
204 int hash, raw; 204 int hash, raw;
205 struct net_protocol *ipprot; 205 const struct net_protocol *ipprot;
206 206
207 resubmit: 207 resubmit:
208 raw = raw_local_deliver(skb, protocol); 208 raw = raw_local_deliver(skb, protocol);
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index 3262ce06294c..38fbf04150ae 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -146,7 +146,7 @@ static const struct xfrm_type ipcomp_type = {
146 .output = ipcomp_output 146 .output = ipcomp_output
147}; 147};
148 148
149static struct net_protocol ipcomp4_protocol = { 149static const struct net_protocol ipcomp4_protocol = {
150 .handler = xfrm4_rcv, 150 .handler = xfrm4_rcv,
151 .err_handler = ipcomp4_err, 151 .err_handler = ipcomp4_err,
152 .no_policy = 1, 152 .no_policy = 1,
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 65d421cf5bc7..c43ec2d51ce2 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -99,10 +99,6 @@ static int ipmr_cache_report(struct net *net,
99 struct sk_buff *pkt, vifi_t vifi, int assert); 99 struct sk_buff *pkt, vifi_t vifi, int assert);
100static int ipmr_fill_mroute(struct sk_buff *skb, struct mfc_cache *c, struct rtmsg *rtm); 100static int ipmr_fill_mroute(struct sk_buff *skb, struct mfc_cache *c, struct rtmsg *rtm);
101 101
102#ifdef CONFIG_IP_PIMSM_V2
103static struct net_protocol pim_protocol;
104#endif
105
106static struct timer_list ipmr_expire_timer; 102static struct timer_list ipmr_expire_timer;
107 103
108/* Service routines creating virtual interfaces: DVMRP tunnels and PIMREG */ 104/* Service routines creating virtual interfaces: DVMRP tunnels and PIMREG */
@@ -1945,7 +1941,7 @@ static const struct file_operations ipmr_mfc_fops = {
1945#endif 1941#endif
1946 1942
1947#ifdef CONFIG_IP_PIMSM_V2 1943#ifdef CONFIG_IP_PIMSM_V2
1948static struct net_protocol pim_protocol = { 1944static const struct net_protocol pim_protocol = {
1949 .handler = pim_rcv, 1945 .handler = pim_rcv,
1950 .netns_ok = 1, 1946 .netns_ok = 1,
1951}; 1947};
diff --git a/net/ipv4/protocol.c b/net/ipv4/protocol.c
index a2e5fc0a15e1..542f22fc98b3 100644
--- a/net/ipv4/protocol.c
+++ b/net/ipv4/protocol.c
@@ -28,14 +28,14 @@
28#include <linux/spinlock.h> 28#include <linux/spinlock.h>
29#include <net/protocol.h> 29#include <net/protocol.h>
30 30
31struct net_protocol *inet_protos[MAX_INET_PROTOS] ____cacheline_aligned_in_smp; 31const struct net_protocol *inet_protos[MAX_INET_PROTOS] ____cacheline_aligned_in_smp;
32static DEFINE_SPINLOCK(inet_proto_lock); 32static DEFINE_SPINLOCK(inet_proto_lock);
33 33
34/* 34/*
35 * Add a protocol handler to the hash tables 35 * Add a protocol handler to the hash tables
36 */ 36 */
37 37
38int inet_add_protocol(struct net_protocol *prot, unsigned char protocol) 38int inet_add_protocol(const struct net_protocol *prot, unsigned char protocol)
39{ 39{
40 int hash, ret; 40 int hash, ret;
41 41
@@ -57,7 +57,7 @@ int inet_add_protocol(struct net_protocol *prot, unsigned char protocol)
57 * Remove a protocol from the hash tables. 57 * Remove a protocol from the hash tables.
58 */ 58 */
59 59
60int inet_del_protocol(struct net_protocol *prot, unsigned char protocol) 60int inet_del_protocol(const struct net_protocol *prot, unsigned char protocol)
61{ 61{
62 int hash, ret; 62 int hash, ret;
63 63
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index edeea060db44..19a0612b8a20 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2012,7 +2012,7 @@ int tcp_disconnect(struct sock *sk, int flags)
2012 tp->snd_cwnd = 2; 2012 tp->snd_cwnd = 2;
2013 icsk->icsk_probes_out = 0; 2013 icsk->icsk_probes_out = 0;
2014 tp->packets_out = 0; 2014 tp->packets_out = 0;
2015 tp->snd_ssthresh = 0x7fffffff; 2015 tp->snd_ssthresh = TCP_INFINITE_SSTHRESH;
2016 tp->snd_cwnd_cnt = 0; 2016 tp->snd_cwnd_cnt = 0;
2017 tp->bytes_acked = 0; 2017 tp->bytes_acked = 0;
2018 tcp_set_ca_state(sk, TCP_CA_Open); 2018 tcp_set_ca_state(sk, TCP_CA_Open);
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index af6d6fa00db1..d86784be7ab3 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -761,7 +761,7 @@ void tcp_update_metrics(struct sock *sk)
761 set_dst_metric_rtt(dst, RTAX_RTTVAR, var); 761 set_dst_metric_rtt(dst, RTAX_RTTVAR, var);
762 } 762 }
763 763
764 if (tp->snd_ssthresh >= 0xFFFF) { 764 if (tcp_in_initial_slowstart(tp)) {
765 /* Slow start still did not finish. */ 765 /* Slow start still did not finish. */
766 if (dst_metric(dst, RTAX_SSTHRESH) && 766 if (dst_metric(dst, RTAX_SSTHRESH) &&
767 !dst_metric_locked(dst, RTAX_SSTHRESH) && 767 !dst_metric_locked(dst, RTAX_SSTHRESH) &&
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 0543561da999..7cda24b53f61 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1808,7 +1808,7 @@ static int tcp_v4_init_sock(struct sock *sk)
1808 /* See draft-stevens-tcpca-spec-01 for discussion of the 1808 /* See draft-stevens-tcpca-spec-01 for discussion of the
1809 * initialization of these values. 1809 * initialization of these values.
1810 */ 1810 */
1811 tp->snd_ssthresh = 0x7fffffff; /* Infinity */ 1811 tp->snd_ssthresh = TCP_INFINITE_SSTHRESH;
1812 tp->snd_cwnd_clamp = ~0; 1812 tp->snd_cwnd_clamp = ~0;
1813 tp->mss_cache = 536; 1813 tp->mss_cache = 536;
1814 1814
@@ -2284,7 +2284,7 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i, int *len)
2284 jiffies_to_clock_t(icsk->icsk_ack.ato), 2284 jiffies_to_clock_t(icsk->icsk_ack.ato),
2285 (icsk->icsk_ack.quick << 1) | icsk->icsk_ack.pingpong, 2285 (icsk->icsk_ack.quick << 1) | icsk->icsk_ack.pingpong,
2286 tp->snd_cwnd, 2286 tp->snd_cwnd,
2287 tp->snd_ssthresh >= 0xFFFF ? -1 : tp->snd_ssthresh, 2287 tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh,
2288 len); 2288 len);
2289} 2289}
2290 2290
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index e48c37d74d77..624c3c9b3c2b 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -363,7 +363,7 @@ void tcp_twsk_destructor(struct sock *sk)
363#ifdef CONFIG_TCP_MD5SIG 363#ifdef CONFIG_TCP_MD5SIG
364 struct tcp_timewait_sock *twsk = tcp_twsk(sk); 364 struct tcp_timewait_sock *twsk = tcp_twsk(sk);
365 if (twsk->tw_md5_keylen) 365 if (twsk->tw_md5_keylen)
366 tcp_put_md5sig_pool(); 366 tcp_free_md5sig_pool();
367#endif 367#endif
368} 368}
369 369
@@ -410,7 +410,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req,
410 newtp->retrans_out = 0; 410 newtp->retrans_out = 0;
411 newtp->sacked_out = 0; 411 newtp->sacked_out = 0;
412 newtp->fackets_out = 0; 412 newtp->fackets_out = 0;
413 newtp->snd_ssthresh = 0x7fffffff; 413 newtp->snd_ssthresh = TCP_INFINITE_SSTHRESH;
414 414
415 /* So many TCP implementations out there (incorrectly) count the 415 /* So many TCP implementations out there (incorrectly) count the
416 * initial SYN frame in their delayed-ACK and congestion control 416 * initial SYN frame in their delayed-ACK and congestion control
diff --git a/net/ipv4/tunnel4.c b/net/ipv4/tunnel4.c
index cb1f0e83830b..3959e0ca456a 100644
--- a/net/ipv4/tunnel4.c
+++ b/net/ipv4/tunnel4.c
@@ -132,7 +132,7 @@ static void tunnel64_err(struct sk_buff *skb, u32 info)
132} 132}
133#endif 133#endif
134 134
135static struct net_protocol tunnel4_protocol = { 135static const struct net_protocol tunnel4_protocol = {
136 .handler = tunnel4_rcv, 136 .handler = tunnel4_rcv,
137 .err_handler = tunnel4_err, 137 .err_handler = tunnel4_err,
138 .no_policy = 1, 138 .no_policy = 1,
@@ -140,7 +140,7 @@ static struct net_protocol tunnel4_protocol = {
140}; 140};
141 141
142#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 142#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
143static struct net_protocol tunnel64_protocol = { 143static const struct net_protocol tunnel64_protocol = {
144 .handler = tunnel64_rcv, 144 .handler = tunnel64_rcv,
145 .err_handler = tunnel64_err, 145 .err_handler = tunnel64_err,
146 .no_policy = 1, 146 .no_policy = 1,
diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c
index c784891cb7e5..95248d7f75ec 100644
--- a/net/ipv4/udplite.c
+++ b/net/ipv4/udplite.c
@@ -25,7 +25,7 @@ static void udplite_err(struct sk_buff *skb, u32 info)
25 __udp4_lib_err(skb, info, &udplite_table); 25 __udp4_lib_err(skb, info, &udplite_table);
26} 26}
27 27
28static struct net_protocol udplite_protocol = { 28static const struct net_protocol udplite_protocol = {
29 .handler = udplite_rcv, 29 .handler = udplite_rcv,
30 .err_handler = udplite_err, 30 .err_handler = udplite_err,
31 .no_policy = 1, 31 .no_policy = 1,
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index c9b369034a40..55f486d89c88 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -137,6 +137,8 @@ static DEFINE_SPINLOCK(addrconf_verify_lock);
137static void addrconf_join_anycast(struct inet6_ifaddr *ifp); 137static void addrconf_join_anycast(struct inet6_ifaddr *ifp);
138static void addrconf_leave_anycast(struct inet6_ifaddr *ifp); 138static void addrconf_leave_anycast(struct inet6_ifaddr *ifp);
139 139
140static void addrconf_bonding_change(struct net_device *dev,
141 unsigned long event);
140static int addrconf_ifdown(struct net_device *dev, int how); 142static int addrconf_ifdown(struct net_device *dev, int how);
141 143
142static void addrconf_dad_start(struct inet6_ifaddr *ifp, u32 flags); 144static void addrconf_dad_start(struct inet6_ifaddr *ifp, u32 flags);
@@ -1405,8 +1407,8 @@ void addrconf_dad_failure(struct inet6_ifaddr *ifp)
1405 struct inet6_dev *idev = ifp->idev; 1407 struct inet6_dev *idev = ifp->idev;
1406 1408
1407 if (net_ratelimit()) 1409 if (net_ratelimit())
1408 printk(KERN_INFO "%s: IPv6 duplicate address detected!\n", 1410 printk(KERN_INFO "%s: IPv6 duplicate address %pI6c detected!\n",
1409 ifp->idev->dev->name); 1411 ifp->idev->dev->name, &ifp->addr);
1410 1412
1411 if (idev->cnf.accept_dad > 1 && !idev->cnf.disable_ipv6) { 1413 if (idev->cnf.accept_dad > 1 && !idev->cnf.disable_ipv6) {
1412 struct in6_addr addr; 1414 struct in6_addr addr;
@@ -2582,6 +2584,10 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
2582 return notifier_from_errno(err); 2584 return notifier_from_errno(err);
2583 } 2585 }
2584 break; 2586 break;
2587 case NETDEV_BONDING_OLDTYPE:
2588 case NETDEV_BONDING_NEWTYPE:
2589 addrconf_bonding_change(dev, event);
2590 break;
2585 } 2591 }
2586 2592
2587 return NOTIFY_OK; 2593 return NOTIFY_OK;
@@ -2595,6 +2601,19 @@ static struct notifier_block ipv6_dev_notf = {
2595 .priority = 0 2601 .priority = 0
2596}; 2602};
2597 2603
2604static void addrconf_bonding_change(struct net_device *dev, unsigned long event)
2605{
2606 struct inet6_dev *idev;
2607 ASSERT_RTNL();
2608
2609 idev = __in6_dev_get(dev);
2610
2611 if (event == NETDEV_BONDING_NEWTYPE)
2612 ipv6_mc_remap(idev);
2613 else if (event == NETDEV_BONDING_OLDTYPE)
2614 ipv6_mc_unmap(idev);
2615}
2616
2598static int addrconf_ifdown(struct net_device *dev, int how) 2617static int addrconf_ifdown(struct net_device *dev, int how)
2599{ 2618{
2600 struct inet6_dev *idev; 2619 struct inet6_dev *idev;
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index a123a328aeb3..e127a32f9540 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -710,7 +710,7 @@ EXPORT_SYMBOL_GPL(ipv6_opt_accepted);
710 710
711static int ipv6_gso_pull_exthdrs(struct sk_buff *skb, int proto) 711static int ipv6_gso_pull_exthdrs(struct sk_buff *skb, int proto)
712{ 712{
713 struct inet6_protocol *ops = NULL; 713 const struct inet6_protocol *ops = NULL;
714 714
715 for (;;) { 715 for (;;) {
716 struct ipv6_opt_hdr *opth; 716 struct ipv6_opt_hdr *opth;
@@ -745,7 +745,7 @@ static int ipv6_gso_pull_exthdrs(struct sk_buff *skb, int proto)
745static int ipv6_gso_send_check(struct sk_buff *skb) 745static int ipv6_gso_send_check(struct sk_buff *skb)
746{ 746{
747 struct ipv6hdr *ipv6h; 747 struct ipv6hdr *ipv6h;
748 struct inet6_protocol *ops; 748 const struct inet6_protocol *ops;
749 int err = -EINVAL; 749 int err = -EINVAL;
750 750
751 if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h)))) 751 if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h))))
@@ -773,7 +773,7 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, int features)
773{ 773{
774 struct sk_buff *segs = ERR_PTR(-EINVAL); 774 struct sk_buff *segs = ERR_PTR(-EINVAL);
775 struct ipv6hdr *ipv6h; 775 struct ipv6hdr *ipv6h;
776 struct inet6_protocol *ops; 776 const struct inet6_protocol *ops;
777 int proto; 777 int proto;
778 struct frag_hdr *fptr; 778 struct frag_hdr *fptr;
779 unsigned int unfrag_ip6hlen; 779 unsigned int unfrag_ip6hlen;
@@ -840,7 +840,7 @@ struct ipv6_gro_cb {
840static struct sk_buff **ipv6_gro_receive(struct sk_buff **head, 840static struct sk_buff **ipv6_gro_receive(struct sk_buff **head,
841 struct sk_buff *skb) 841 struct sk_buff *skb)
842{ 842{
843 struct inet6_protocol *ops; 843 const struct inet6_protocol *ops;
844 struct sk_buff **pp = NULL; 844 struct sk_buff **pp = NULL;
845 struct sk_buff *p; 845 struct sk_buff *p;
846 struct ipv6hdr *iph; 846 struct ipv6hdr *iph;
@@ -926,7 +926,7 @@ out:
926 926
927static int ipv6_gro_complete(struct sk_buff *skb) 927static int ipv6_gro_complete(struct sk_buff *skb)
928{ 928{
929 struct inet6_protocol *ops; 929 const struct inet6_protocol *ops;
930 struct ipv6hdr *iph = ipv6_hdr(skb); 930 struct ipv6hdr *iph = ipv6_hdr(skb);
931 int err = -ENOSYS; 931 int err = -ENOSYS;
932 932
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c
index 86f42a288c4b..c1589e2f1dc9 100644
--- a/net/ipv6/ah6.c
+++ b/net/ipv6/ah6.c
@@ -527,7 +527,7 @@ static const struct xfrm_type ah6_type =
527 .hdr_offset = xfrm6_find_1stfragopt, 527 .hdr_offset = xfrm6_find_1stfragopt,
528}; 528};
529 529
530static struct inet6_protocol ah6_protocol = { 530static const struct inet6_protocol ah6_protocol = {
531 .handler = xfrm6_rcv, 531 .handler = xfrm6_rcv,
532 .err_handler = ah6_err, 532 .err_handler = ah6_err,
533 .flags = INET6_PROTO_NOPOLICY, 533 .flags = INET6_PROTO_NOPOLICY,
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 678bb95b1525..af597c73ebe9 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -558,7 +558,7 @@ static const struct xfrm_type esp6_type =
558 .hdr_offset = xfrm6_find_1stfragopt, 558 .hdr_offset = xfrm6_find_1stfragopt,
559}; 559};
560 560
561static struct inet6_protocol esp6_protocol = { 561static const struct inet6_protocol esp6_protocol = {
562 .handler = xfrm6_rcv, 562 .handler = xfrm6_rcv,
563 .err_handler = esp6_err, 563 .err_handler = esp6_err,
564 .flags = INET6_PROTO_NOPOLICY, 564 .flags = INET6_PROTO_NOPOLICY,
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 4aae658e5501..df159fffe4bc 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -500,17 +500,17 @@ unknown_rh:
500 return -1; 500 return -1;
501} 501}
502 502
503static struct inet6_protocol rthdr_protocol = { 503static const struct inet6_protocol rthdr_protocol = {
504 .handler = ipv6_rthdr_rcv, 504 .handler = ipv6_rthdr_rcv,
505 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR, 505 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR,
506}; 506};
507 507
508static struct inet6_protocol destopt_protocol = { 508static const struct inet6_protocol destopt_protocol = {
509 .handler = ipv6_destopt_rcv, 509 .handler = ipv6_destopt_rcv,
510 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR, 510 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR,
511}; 511};
512 512
513static struct inet6_protocol nodata_protocol = { 513static const struct inet6_protocol nodata_protocol = {
514 .handler = dst_discard, 514 .handler = dst_discard,
515 .flags = INET6_PROTO_NOPOLICY, 515 .flags = INET6_PROTO_NOPOLICY,
516}; 516};
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index e2325f6a05fb..f23ebbec0631 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -86,7 +86,7 @@ static inline struct sock *icmpv6_sk(struct net *net)
86 86
87static int icmpv6_rcv(struct sk_buff *skb); 87static int icmpv6_rcv(struct sk_buff *skb);
88 88
89static struct inet6_protocol icmpv6_protocol = { 89static const struct inet6_protocol icmpv6_protocol = {
90 .handler = icmpv6_rcv, 90 .handler = icmpv6_rcv,
91 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, 91 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
92}; 92};
@@ -583,7 +583,7 @@ out:
583 583
584static void icmpv6_notify(struct sk_buff *skb, u8 type, u8 code, __be32 info) 584static void icmpv6_notify(struct sk_buff *skb, u8 type, u8 code, __be32 info)
585{ 585{
586 struct inet6_protocol *ipprot; 586 const struct inet6_protocol *ipprot;
587 int inner_offset; 587 int inner_offset;
588 int hash; 588 int hash;
589 u8 nexthdr; 589 u8 nexthdr;
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index 2d9cbaa67edb..237e2dba6e94 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -159,7 +159,7 @@ drop:
159 159
160static int ip6_input_finish(struct sk_buff *skb) 160static int ip6_input_finish(struct sk_buff *skb)
161{ 161{
162 struct inet6_protocol *ipprot; 162 const struct inet6_protocol *ipprot;
163 unsigned int nhoff; 163 unsigned int nhoff;
164 int nexthdr, raw; 164 int nexthdr, raw;
165 u8 hash; 165 u8 hash;
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 5c8d73730c75..3907510c2ce3 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -83,10 +83,6 @@ static int ip6mr_cache_report(struct net *net, struct sk_buff *pkt,
83static int ip6mr_fill_mroute(struct sk_buff *skb, struct mfc6_cache *c, struct rtmsg *rtm); 83static int ip6mr_fill_mroute(struct sk_buff *skb, struct mfc6_cache *c, struct rtmsg *rtm);
84static void mroute_clean_tables(struct net *net); 84static void mroute_clean_tables(struct net *net);
85 85
86#ifdef CONFIG_IPV6_PIMSM_V2
87static struct inet6_protocol pim6_protocol;
88#endif
89
90static struct timer_list ipmr_expire_timer; 86static struct timer_list ipmr_expire_timer;
91 87
92 88
@@ -410,7 +406,7 @@ static int pim6_rcv(struct sk_buff *skb)
410 return 0; 406 return 0;
411} 407}
412 408
413static struct inet6_protocol pim6_protocol = { 409static const struct inet6_protocol pim6_protocol = {
414 .handler = pim6_rcv, 410 .handler = pim6_rcv,
415}; 411};
416 412
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
index 79c172f1ff01..2f2a5ca2c878 100644
--- a/net/ipv6/ipcomp6.c
+++ b/net/ipv6/ipcomp6.c
@@ -178,7 +178,7 @@ static const struct xfrm_type ipcomp6_type =
178 .hdr_offset = xfrm6_find_1stfragopt, 178 .hdr_offset = xfrm6_find_1stfragopt,
179}; 179};
180 180
181static struct inet6_protocol ipcomp6_protocol = 181static const struct inet6_protocol ipcomp6_protocol =
182{ 182{
183 .handler = xfrm6_rcv, 183 .handler = xfrm6_rcv,
184 .err_handler = ipcomp6_err, 184 .err_handler = ipcomp6_err,
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 71c3dacec1ed..f9fcf690bd5d 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -2249,6 +2249,25 @@ static void igmp6_timer_handler(unsigned long data)
2249 ma_put(ma); 2249 ma_put(ma);
2250} 2250}
2251 2251
2252/* Device changing type */
2253
2254void ipv6_mc_unmap(struct inet6_dev *idev)
2255{
2256 struct ifmcaddr6 *i;
2257
2258 /* Install multicast list, except for all-nodes (already installed) */
2259
2260 read_lock_bh(&idev->lock);
2261 for (i = idev->mc_list; i; i = i->next)
2262 igmp6_group_dropped(i);
2263 read_unlock_bh(&idev->lock);
2264}
2265
2266void ipv6_mc_remap(struct inet6_dev *idev)
2267{
2268 ipv6_mc_up(idev);
2269}
2270
2252/* Device going down */ 2271/* Device going down */
2253 2272
2254void ipv6_mc_down(struct inet6_dev *idev) 2273void ipv6_mc_down(struct inet6_dev *idev)
diff --git a/net/ipv6/protocol.c b/net/ipv6/protocol.c
index 568864f722ca..1fa3468f0f32 100644
--- a/net/ipv6/protocol.c
+++ b/net/ipv6/protocol.c
@@ -25,11 +25,11 @@
25#include <linux/spinlock.h> 25#include <linux/spinlock.h>
26#include <net/protocol.h> 26#include <net/protocol.h>
27 27
28struct inet6_protocol *inet6_protos[MAX_INET_PROTOS]; 28const struct inet6_protocol *inet6_protos[MAX_INET_PROTOS];
29static DEFINE_SPINLOCK(inet6_proto_lock); 29static DEFINE_SPINLOCK(inet6_proto_lock);
30 30
31 31
32int inet6_add_protocol(struct inet6_protocol *prot, unsigned char protocol) 32int inet6_add_protocol(const struct inet6_protocol *prot, unsigned char protocol)
33{ 33{
34 int ret, hash = protocol & (MAX_INET_PROTOS - 1); 34 int ret, hash = protocol & (MAX_INET_PROTOS - 1);
35 35
@@ -53,7 +53,7 @@ EXPORT_SYMBOL(inet6_add_protocol);
53 * Remove a protocol from the hash tables. 53 * Remove a protocol from the hash tables.
54 */ 54 */
55 55
56int inet6_del_protocol(struct inet6_protocol *prot, unsigned char protocol) 56int inet6_del_protocol(const struct inet6_protocol *prot, unsigned char protocol)
57{ 57{
58 int ret, hash = protocol & (MAX_INET_PROTOS - 1); 58 int ret, hash = protocol & (MAX_INET_PROTOS - 1);
59 59
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 2642a41a8535..da5bd0ed83df 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -627,7 +627,7 @@ fail_hdr:
627 return -1; 627 return -1;
628} 628}
629 629
630static struct inet6_protocol frag_protocol = 630static const struct inet6_protocol frag_protocol =
631{ 631{
632 .handler = ipv6_frag_rcv, 632 .handler = ipv6_frag_rcv,
633 .flags = INET6_PROTO_NOPOLICY, 633 .flags = INET6_PROTO_NOPOLICY,
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 9ccfef345560..77aecbe8ff6c 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -481,7 +481,7 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len,
481 481
482 pref = rinfo->route_pref; 482 pref = rinfo->route_pref;
483 if (pref == ICMPV6_ROUTER_PREF_INVALID) 483 if (pref == ICMPV6_ROUTER_PREF_INVALID)
484 pref = ICMPV6_ROUTER_PREF_MEDIUM; 484 return -EINVAL;
485 485
486 lifetime = addrconf_timeout_fixup(ntohl(rinfo->lifetime), HZ); 486 lifetime = addrconf_timeout_fixup(ntohl(rinfo->lifetime), HZ);
487 487
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 3aae0f217d61..21d100b68b19 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1846,7 +1846,7 @@ static int tcp_v6_init_sock(struct sock *sk)
1846 /* See draft-stevens-tcpca-spec-01 for discussion of the 1846 /* See draft-stevens-tcpca-spec-01 for discussion of the
1847 * initialization of these values. 1847 * initialization of these values.
1848 */ 1848 */
1849 tp->snd_ssthresh = 0x7fffffff; 1849 tp->snd_ssthresh = TCP_INFINITE_SSTHRESH;
1850 tp->snd_cwnd_clamp = ~0; 1850 tp->snd_cwnd_clamp = ~0;
1851 tp->mss_cache = 536; 1851 tp->mss_cache = 536;
1852 1852
@@ -1969,7 +1969,8 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
1969 jiffies_to_clock_t(icsk->icsk_rto), 1969 jiffies_to_clock_t(icsk->icsk_rto),
1970 jiffies_to_clock_t(icsk->icsk_ack.ato), 1970 jiffies_to_clock_t(icsk->icsk_ack.ato),
1971 (icsk->icsk_ack.quick << 1 ) | icsk->icsk_ack.pingpong, 1971 (icsk->icsk_ack.quick << 1 ) | icsk->icsk_ack.pingpong,
1972 tp->snd_cwnd, tp->snd_ssthresh>=0xFFFF?-1:tp->snd_ssthresh 1972 tp->snd_cwnd,
1973 tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh
1973 ); 1974 );
1974} 1975}
1975 1976
@@ -2093,7 +2094,7 @@ struct proto tcpv6_prot = {
2093#endif 2094#endif
2094}; 2095};
2095 2096
2096static struct inet6_protocol tcpv6_protocol = { 2097static const struct inet6_protocol tcpv6_protocol = {
2097 .handler = tcp_v6_rcv, 2098 .handler = tcp_v6_rcv,
2098 .err_handler = tcp_v6_err, 2099 .err_handler = tcp_v6_err,
2099 .gso_send_check = tcp_v6_gso_send_check, 2100 .gso_send_check = tcp_v6_gso_send_check,
diff --git a/net/ipv6/tunnel6.c b/net/ipv6/tunnel6.c
index 633ad789effc..51e2832d13a6 100644
--- a/net/ipv6/tunnel6.c
+++ b/net/ipv6/tunnel6.c
@@ -133,13 +133,13 @@ static void tunnel6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
133 break; 133 break;
134} 134}
135 135
136static struct inet6_protocol tunnel6_protocol = { 136static const struct inet6_protocol tunnel6_protocol = {
137 .handler = tunnel6_rcv, 137 .handler = tunnel6_rcv,
138 .err_handler = tunnel6_err, 138 .err_handler = tunnel6_err,
139 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, 139 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
140}; 140};
141 141
142static struct inet6_protocol tunnel46_protocol = { 142static const struct inet6_protocol tunnel46_protocol = {
143 .handler = tunnel46_rcv, 143 .handler = tunnel46_rcv,
144 .err_handler = tunnel6_err, 144 .err_handler = tunnel6_err,
145 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, 145 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 164040613c2e..b265b7047d3e 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1172,7 +1172,7 @@ out:
1172 return segs; 1172 return segs;
1173} 1173}
1174 1174
1175static struct inet6_protocol udpv6_protocol = { 1175static const struct inet6_protocol udpv6_protocol = {
1176 .handler = udpv6_rcv, 1176 .handler = udpv6_rcv,
1177 .err_handler = udpv6_err, 1177 .err_handler = udpv6_err,
1178 .gso_send_check = udp6_ufo_send_check, 1178 .gso_send_check = udp6_ufo_send_check,
diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c
index 4818c48688f2..d737a27ee010 100644
--- a/net/ipv6/udplite.c
+++ b/net/ipv6/udplite.c
@@ -25,7 +25,7 @@ static void udplitev6_err(struct sk_buff *skb,
25 __udp6_lib_err(skb, opt, type, code, offset, info, &udplite_table); 25 __udp6_lib_err(skb, opt, type, code, offset, info, &udplite_table);
26} 26}
27 27
28static struct inet6_protocol udplitev6_protocol = { 28static const struct inet6_protocol udplitev6_protocol = {
29 .handler = udplitev6_rcv, 29 .handler = udplitev6_rcv,
30 .err_handler = udplitev6_err, 30 .err_handler = udplitev6_err,
31 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, 31 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index 49c15b48408e..d985d163dcfc 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -34,7 +34,7 @@
34 34
35static char iucv_userid[80]; 35static char iucv_userid[80];
36 36
37static struct proto_ops iucv_sock_ops; 37static const struct proto_ops iucv_sock_ops;
38 38
39static struct proto iucv_proto = { 39static struct proto iucv_proto = {
40 .name = "AF_IUCV", 40 .name = "AF_IUCV",
@@ -59,8 +59,8 @@ do { \
59 DEFINE_WAIT(__wait); \ 59 DEFINE_WAIT(__wait); \
60 long __timeo = timeo; \ 60 long __timeo = timeo; \
61 ret = 0; \ 61 ret = 0; \
62 prepare_to_wait(sk->sk_sleep, &__wait, TASK_INTERRUPTIBLE); \
62 while (!(condition)) { \ 63 while (!(condition)) { \
63 prepare_to_wait(sk->sk_sleep, &__wait, TASK_INTERRUPTIBLE); \
64 if (!__timeo) { \ 64 if (!__timeo) { \
65 ret = -EAGAIN; \ 65 ret = -EAGAIN; \
66 break; \ 66 break; \
@@ -361,10 +361,9 @@ static void iucv_sock_cleanup_listen(struct sock *parent)
361 } 361 }
362 362
363 parent->sk_state = IUCV_CLOSED; 363 parent->sk_state = IUCV_CLOSED;
364 sock_set_flag(parent, SOCK_ZAPPED);
365} 364}
366 365
367/* Kill socket */ 366/* Kill socket (only if zapped and orphaned) */
368static void iucv_sock_kill(struct sock *sk) 367static void iucv_sock_kill(struct sock *sk)
369{ 368{
370 if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket) 369 if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket)
@@ -426,17 +425,18 @@ static void iucv_sock_close(struct sock *sk)
426 425
427 skb_queue_purge(&iucv->send_skb_q); 426 skb_queue_purge(&iucv->send_skb_q);
428 skb_queue_purge(&iucv->backlog_skb_q); 427 skb_queue_purge(&iucv->backlog_skb_q);
429
430 sock_set_flag(sk, SOCK_ZAPPED);
431 break; 428 break;
432 429
433 default: 430 default:
434 sock_set_flag(sk, SOCK_ZAPPED); 431 sock_set_flag(sk, SOCK_ZAPPED);
432 /* nothing to do here */
435 break; 433 break;
436 } 434 }
437 435
436 /* mark socket for deletion by iucv_sock_kill() */
437 sock_set_flag(sk, SOCK_ZAPPED);
438
438 release_sock(sk); 439 release_sock(sk);
439 iucv_sock_kill(sk);
440} 440}
441 441
442static void iucv_sock_init(struct sock *sk, struct sock *parent) 442static void iucv_sock_init(struct sock *sk, struct sock *parent)
@@ -569,6 +569,7 @@ struct sock *iucv_accept_dequeue(struct sock *parent, struct socket *newsock)
569 569
570 if (sk->sk_state == IUCV_CONNECTED || 570 if (sk->sk_state == IUCV_CONNECTED ||
571 sk->sk_state == IUCV_SEVERED || 571 sk->sk_state == IUCV_SEVERED ||
572 sk->sk_state == IUCV_DISCONN || /* due to PM restore */
572 !newsock) { 573 !newsock) {
573 iucv_accept_unlink(sk); 574 iucv_accept_unlink(sk);
574 if (newsock) 575 if (newsock)
@@ -1035,6 +1036,10 @@ out:
1035 return err; 1036 return err;
1036} 1037}
1037 1038
1039/* iucv_fragment_skb() - Fragment a single IUCV message into multiple skb's
1040 *
1041 * Locking: must be called with message_q.lock held
1042 */
1038static int iucv_fragment_skb(struct sock *sk, struct sk_buff *skb, int len) 1043static int iucv_fragment_skb(struct sock *sk, struct sk_buff *skb, int len)
1039{ 1044{
1040 int dataleft, size, copied = 0; 1045 int dataleft, size, copied = 0;
@@ -1069,6 +1074,10 @@ static int iucv_fragment_skb(struct sock *sk, struct sk_buff *skb, int len)
1069 return 0; 1074 return 0;
1070} 1075}
1071 1076
1077/* iucv_process_message() - Receive a single outstanding IUCV message
1078 *
1079 * Locking: must be called with message_q.lock held
1080 */
1072static void iucv_process_message(struct sock *sk, struct sk_buff *skb, 1081static void iucv_process_message(struct sock *sk, struct sk_buff *skb,
1073 struct iucv_path *path, 1082 struct iucv_path *path,
1074 struct iucv_message *msg) 1083 struct iucv_message *msg)
@@ -1119,6 +1128,10 @@ static void iucv_process_message(struct sock *sk, struct sk_buff *skb,
1119 skb_queue_head(&iucv_sk(sk)->backlog_skb_q, skb); 1128 skb_queue_head(&iucv_sk(sk)->backlog_skb_q, skb);
1120} 1129}
1121 1130
1131/* iucv_process_message_q() - Process outstanding IUCV messages
1132 *
1133 * Locking: must be called with message_q.lock held
1134 */
1122static void iucv_process_message_q(struct sock *sk) 1135static void iucv_process_message_q(struct sock *sk)
1123{ 1136{
1124 struct iucv_sock *iucv = iucv_sk(sk); 1137 struct iucv_sock *iucv = iucv_sk(sk);
@@ -1209,6 +1222,7 @@ static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
1209 kfree_skb(skb); 1222 kfree_skb(skb);
1210 1223
1211 /* Queue backlog skbs */ 1224 /* Queue backlog skbs */
1225 spin_lock_bh(&iucv->message_q.lock);
1212 rskb = skb_dequeue(&iucv->backlog_skb_q); 1226 rskb = skb_dequeue(&iucv->backlog_skb_q);
1213 while (rskb) { 1227 while (rskb) {
1214 if (sock_queue_rcv_skb(sk, rskb)) { 1228 if (sock_queue_rcv_skb(sk, rskb)) {
@@ -1220,11 +1234,10 @@ static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
1220 } 1234 }
1221 } 1235 }
1222 if (skb_queue_empty(&iucv->backlog_skb_q)) { 1236 if (skb_queue_empty(&iucv->backlog_skb_q)) {
1223 spin_lock_bh(&iucv->message_q.lock);
1224 if (!list_empty(&iucv->message_q.list)) 1237 if (!list_empty(&iucv->message_q.list))
1225 iucv_process_message_q(sk); 1238 iucv_process_message_q(sk);
1226 spin_unlock_bh(&iucv->message_q.lock);
1227 } 1239 }
1240 spin_unlock_bh(&iucv->message_q.lock);
1228 } 1241 }
1229 1242
1230done: 1243done:
@@ -1682,7 +1695,7 @@ static void iucv_callback_shutdown(struct iucv_path *path, u8 ipuser[16])
1682 bh_unlock_sock(sk); 1695 bh_unlock_sock(sk);
1683} 1696}
1684 1697
1685static struct proto_ops iucv_sock_ops = { 1698static const struct proto_ops iucv_sock_ops = {
1686 .family = PF_IUCV, 1699 .family = PF_IUCV,
1687 .owner = THIS_MODULE, 1700 .owner = THIS_MODULE,
1688 .release = iucv_sock_release, 1701 .release = iucv_sock_release,
diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
index c833481d32e3..3973d0e61e56 100644
--- a/net/iucv/iucv.c
+++ b/net/iucv/iucv.c
@@ -79,6 +79,14 @@ static int iucv_bus_match(struct device *dev, struct device_driver *drv)
79 return 0; 79 return 0;
80} 80}
81 81
82enum iucv_pm_states {
83 IUCV_PM_INITIAL = 0,
84 IUCV_PM_FREEZING = 1,
85 IUCV_PM_THAWING = 2,
86 IUCV_PM_RESTORING = 3,
87};
88static enum iucv_pm_states iucv_pm_state;
89
82static int iucv_pm_prepare(struct device *); 90static int iucv_pm_prepare(struct device *);
83static void iucv_pm_complete(struct device *); 91static void iucv_pm_complete(struct device *);
84static int iucv_pm_freeze(struct device *); 92static int iucv_pm_freeze(struct device *);
@@ -354,7 +362,7 @@ static int iucv_query_maxconn(void)
354 " srl %0,28\n" 362 " srl %0,28\n"
355 : "=d" (ccode), "+d" (reg0), "+d" (reg1) : : "cc"); 363 : "=d" (ccode), "+d" (reg0), "+d" (reg1) : : "cc");
356 if (ccode == 0) 364 if (ccode == 0)
357 iucv_max_pathid = reg0; 365 iucv_max_pathid = reg1;
358 kfree(param); 366 kfree(param);
359 return ccode ? -EPERM : 0; 367 return ccode ? -EPERM : 0;
360} 368}
@@ -856,7 +864,7 @@ int iucv_path_accept(struct iucv_path *path, struct iucv_handler *handler,
856 int rc; 864 int rc;
857 865
858 local_bh_disable(); 866 local_bh_disable();
859 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 867 if (cpus_empty(iucv_buffer_cpumask)) {
860 rc = -EIO; 868 rc = -EIO;
861 goto out; 869 goto out;
862 } 870 }
@@ -905,7 +913,7 @@ int iucv_path_connect(struct iucv_path *path, struct iucv_handler *handler,
905 913
906 spin_lock_bh(&iucv_table_lock); 914 spin_lock_bh(&iucv_table_lock);
907 iucv_cleanup_queue(); 915 iucv_cleanup_queue();
908 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 916 if (cpus_empty(iucv_buffer_cpumask)) {
909 rc = -EIO; 917 rc = -EIO;
910 goto out; 918 goto out;
911 } 919 }
@@ -965,7 +973,7 @@ int iucv_path_quiesce(struct iucv_path *path, u8 userdata[16])
965 int rc; 973 int rc;
966 974
967 local_bh_disable(); 975 local_bh_disable();
968 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 976 if (cpus_empty(iucv_buffer_cpumask)) {
969 rc = -EIO; 977 rc = -EIO;
970 goto out; 978 goto out;
971 } 979 }
@@ -997,7 +1005,7 @@ int iucv_path_resume(struct iucv_path *path, u8 userdata[16])
997 int rc; 1005 int rc;
998 1006
999 local_bh_disable(); 1007 local_bh_disable();
1000 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 1008 if (cpus_empty(iucv_buffer_cpumask)) {
1001 rc = -EIO; 1009 rc = -EIO;
1002 goto out; 1010 goto out;
1003 } 1011 }
@@ -1026,7 +1034,7 @@ int iucv_path_sever(struct iucv_path *path, u8 userdata[16])
1026 int rc; 1034 int rc;
1027 1035
1028 preempt_disable(); 1036 preempt_disable();
1029 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 1037 if (cpus_empty(iucv_buffer_cpumask)) {
1030 rc = -EIO; 1038 rc = -EIO;
1031 goto out; 1039 goto out;
1032 } 1040 }
@@ -1060,7 +1068,7 @@ int iucv_message_purge(struct iucv_path *path, struct iucv_message *msg,
1060 int rc; 1068 int rc;
1061 1069
1062 local_bh_disable(); 1070 local_bh_disable();
1063 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 1071 if (cpus_empty(iucv_buffer_cpumask)) {
1064 rc = -EIO; 1072 rc = -EIO;
1065 goto out; 1073 goto out;
1066 } 1074 }
@@ -1152,7 +1160,7 @@ int __iucv_message_receive(struct iucv_path *path, struct iucv_message *msg,
1152 if (msg->flags & IUCV_IPRMDATA) 1160 if (msg->flags & IUCV_IPRMDATA)
1153 return iucv_message_receive_iprmdata(path, msg, flags, 1161 return iucv_message_receive_iprmdata(path, msg, flags,
1154 buffer, size, residual); 1162 buffer, size, residual);
1155 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 1163 if (cpus_empty(iucv_buffer_cpumask)) {
1156 rc = -EIO; 1164 rc = -EIO;
1157 goto out; 1165 goto out;
1158 } 1166 }
@@ -1225,7 +1233,7 @@ int iucv_message_reject(struct iucv_path *path, struct iucv_message *msg)
1225 int rc; 1233 int rc;
1226 1234
1227 local_bh_disable(); 1235 local_bh_disable();
1228 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 1236 if (cpus_empty(iucv_buffer_cpumask)) {
1229 rc = -EIO; 1237 rc = -EIO;
1230 goto out; 1238 goto out;
1231 } 1239 }
@@ -1264,7 +1272,7 @@ int iucv_message_reply(struct iucv_path *path, struct iucv_message *msg,
1264 int rc; 1272 int rc;
1265 1273
1266 local_bh_disable(); 1274 local_bh_disable();
1267 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 1275 if (cpus_empty(iucv_buffer_cpumask)) {
1268 rc = -EIO; 1276 rc = -EIO;
1269 goto out; 1277 goto out;
1270 } 1278 }
@@ -1314,7 +1322,7 @@ int __iucv_message_send(struct iucv_path *path, struct iucv_message *msg,
1314 union iucv_param *parm; 1322 union iucv_param *parm;
1315 int rc; 1323 int rc;
1316 1324
1317 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 1325 if (cpus_empty(iucv_buffer_cpumask)) {
1318 rc = -EIO; 1326 rc = -EIO;
1319 goto out; 1327 goto out;
1320 } 1328 }
@@ -1401,7 +1409,7 @@ int iucv_message_send2way(struct iucv_path *path, struct iucv_message *msg,
1401 int rc; 1409 int rc;
1402 1410
1403 local_bh_disable(); 1411 local_bh_disable();
1404 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 1412 if (cpus_empty(iucv_buffer_cpumask)) {
1405 rc = -EIO; 1413 rc = -EIO;
1406 goto out; 1414 goto out;
1407 } 1415 }
@@ -1875,6 +1883,7 @@ static int iucv_pm_freeze(struct device *dev)
1875#ifdef CONFIG_PM_DEBUG 1883#ifdef CONFIG_PM_DEBUG
1876 printk(KERN_WARNING "iucv_pm_freeze\n"); 1884 printk(KERN_WARNING "iucv_pm_freeze\n");
1877#endif 1885#endif
1886 iucv_pm_state = IUCV_PM_FREEZING;
1878 for_each_cpu_mask_nr(cpu, iucv_irq_cpumask) 1887 for_each_cpu_mask_nr(cpu, iucv_irq_cpumask)
1879 smp_call_function_single(cpu, iucv_block_cpu_almost, NULL, 1); 1888 smp_call_function_single(cpu, iucv_block_cpu_almost, NULL, 1);
1880 if (dev->driver && dev->driver->pm && dev->driver->pm->freeze) 1889 if (dev->driver && dev->driver->pm && dev->driver->pm->freeze)
@@ -1899,6 +1908,7 @@ static int iucv_pm_thaw(struct device *dev)
1899#ifdef CONFIG_PM_DEBUG 1908#ifdef CONFIG_PM_DEBUG
1900 printk(KERN_WARNING "iucv_pm_thaw\n"); 1909 printk(KERN_WARNING "iucv_pm_thaw\n");
1901#endif 1910#endif
1911 iucv_pm_state = IUCV_PM_THAWING;
1902 if (!iucv_path_table) { 1912 if (!iucv_path_table) {
1903 rc = iucv_enable(); 1913 rc = iucv_enable();
1904 if (rc) 1914 if (rc)
@@ -1933,6 +1943,10 @@ static int iucv_pm_restore(struct device *dev)
1933#ifdef CONFIG_PM_DEBUG 1943#ifdef CONFIG_PM_DEBUG
1934 printk(KERN_WARNING "iucv_pm_restore %p\n", iucv_path_table); 1944 printk(KERN_WARNING "iucv_pm_restore %p\n", iucv_path_table);
1935#endif 1945#endif
1946 if ((iucv_pm_state != IUCV_PM_RESTORING) && iucv_path_table)
1947 pr_warning("Suspending Linux did not completely close all IUCV "
1948 "connections\n");
1949 iucv_pm_state = IUCV_PM_RESTORING;
1936 if (cpus_empty(iucv_irq_cpumask)) { 1950 if (cpus_empty(iucv_irq_cpumask)) {
1937 rc = iucv_query_maxconn(); 1951 rc = iucv_query_maxconn();
1938 rc = iucv_enable(); 1952 rc = iucv_enable();
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c
index 7c5142988bbb..6e5d68b4e427 100644
--- a/net/mac80211/rc80211_minstrel.c
+++ b/net/mac80211/rc80211_minstrel.c
@@ -418,7 +418,7 @@ minstrel_rate_init(void *priv, struct ieee80211_supported_band *sband,
418 418
419 /* contention window */ 419 /* contention window */
420 tx_time_single += t_slot + min(cw, mp->cw_max); 420 tx_time_single += t_slot + min(cw, mp->cw_max);
421 cw = (cw + 1) << 1; 421 cw = (cw << 1) | 1;
422 422
423 tx_time += tx_time_single; 423 tx_time += tx_time_single;
424 tx_time_cts += tx_time_single + mi->sp_ack_dur; 424 tx_time_cts += tx_time_single + mi->sp_ack_dur;
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index d0ff382c40ca..c5aab6a368ce 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -177,9 +177,11 @@ static void netlink_sock_destruct(struct sock *sk)
177 * this, _but_ remember, it adds useless work on UP machines. 177 * this, _but_ remember, it adds useless work on UP machines.
178 */ 178 */
179 179
180static void netlink_table_grab(void) 180void netlink_table_grab(void)
181 __acquires(nl_table_lock) 181 __acquires(nl_table_lock)
182{ 182{
183 might_sleep();
184
183 write_lock_irq(&nl_table_lock); 185 write_lock_irq(&nl_table_lock);
184 186
185 if (atomic_read(&nl_table_users)) { 187 if (atomic_read(&nl_table_users)) {
@@ -200,7 +202,7 @@ static void netlink_table_grab(void)
200 } 202 }
201} 203}
202 204
203static void netlink_table_ungrab(void) 205void netlink_table_ungrab(void)
204 __releases(nl_table_lock) 206 __releases(nl_table_lock)
205{ 207{
206 write_unlock_irq(&nl_table_lock); 208 write_unlock_irq(&nl_table_lock);
@@ -1549,37 +1551,21 @@ static void netlink_free_old_listeners(struct rcu_head *rcu_head)
1549 kfree(lrh->ptr); 1551 kfree(lrh->ptr);
1550} 1552}
1551 1553
1552/** 1554int __netlink_change_ngroups(struct sock *sk, unsigned int groups)
1553 * netlink_change_ngroups - change number of multicast groups
1554 *
1555 * This changes the number of multicast groups that are available
1556 * on a certain netlink family. Note that it is not possible to
1557 * change the number of groups to below 32. Also note that it does
1558 * not implicitly call netlink_clear_multicast_users() when the
1559 * number of groups is reduced.
1560 *
1561 * @sk: The kernel netlink socket, as returned by netlink_kernel_create().
1562 * @groups: The new number of groups.
1563 */
1564int netlink_change_ngroups(struct sock *sk, unsigned int groups)
1565{ 1555{
1566 unsigned long *listeners, *old = NULL; 1556 unsigned long *listeners, *old = NULL;
1567 struct listeners_rcu_head *old_rcu_head; 1557 struct listeners_rcu_head *old_rcu_head;
1568 struct netlink_table *tbl = &nl_table[sk->sk_protocol]; 1558 struct netlink_table *tbl = &nl_table[sk->sk_protocol];
1569 int err = 0;
1570 1559
1571 if (groups < 32) 1560 if (groups < 32)
1572 groups = 32; 1561 groups = 32;
1573 1562
1574 netlink_table_grab();
1575 if (NLGRPSZ(tbl->groups) < NLGRPSZ(groups)) { 1563 if (NLGRPSZ(tbl->groups) < NLGRPSZ(groups)) {
1576 listeners = kzalloc(NLGRPSZ(groups) + 1564 listeners = kzalloc(NLGRPSZ(groups) +
1577 sizeof(struct listeners_rcu_head), 1565 sizeof(struct listeners_rcu_head),
1578 GFP_ATOMIC); 1566 GFP_ATOMIC);
1579 if (!listeners) { 1567 if (!listeners)
1580 err = -ENOMEM; 1568 return -ENOMEM;
1581 goto out_ungrab;
1582 }
1583 old = tbl->listeners; 1569 old = tbl->listeners;
1584 memcpy(listeners, old, NLGRPSZ(tbl->groups)); 1570 memcpy(listeners, old, NLGRPSZ(tbl->groups));
1585 rcu_assign_pointer(tbl->listeners, listeners); 1571 rcu_assign_pointer(tbl->listeners, listeners);
@@ -1597,8 +1583,29 @@ int netlink_change_ngroups(struct sock *sk, unsigned int groups)
1597 } 1583 }
1598 tbl->groups = groups; 1584 tbl->groups = groups;
1599 1585
1600 out_ungrab: 1586 return 0;
1587}
1588
1589/**
1590 * netlink_change_ngroups - change number of multicast groups
1591 *
1592 * This changes the number of multicast groups that are available
1593 * on a certain netlink family. Note that it is not possible to
1594 * change the number of groups to below 32. Also note that it does
1595 * not implicitly call netlink_clear_multicast_users() when the
1596 * number of groups is reduced.
1597 *
1598 * @sk: The kernel netlink socket, as returned by netlink_kernel_create().
1599 * @groups: The new number of groups.
1600 */
1601int netlink_change_ngroups(struct sock *sk, unsigned int groups)
1602{
1603 int err;
1604
1605 netlink_table_grab();
1606 err = __netlink_change_ngroups(sk, groups);
1601 netlink_table_ungrab(); 1607 netlink_table_ungrab();
1608
1602 return err; 1609 return err;
1603} 1610}
1604 1611
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 66f6ba0bab11..566941e03363 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -176,9 +176,10 @@ int genl_register_mc_group(struct genl_family *family,
176 if (family->netnsok) { 176 if (family->netnsok) {
177 struct net *net; 177 struct net *net;
178 178
179 netlink_table_grab();
179 rcu_read_lock(); 180 rcu_read_lock();
180 for_each_net_rcu(net) { 181 for_each_net_rcu(net) {
181 err = netlink_change_ngroups(net->genl_sock, 182 err = __netlink_change_ngroups(net->genl_sock,
182 mc_groups_longs * BITS_PER_LONG); 183 mc_groups_longs * BITS_PER_LONG);
183 if (err) { 184 if (err) {
184 /* 185 /*
@@ -188,10 +189,12 @@ int genl_register_mc_group(struct genl_family *family,
188 * increased on some sockets which is ok. 189 * increased on some sockets which is ok.
189 */ 190 */
190 rcu_read_unlock(); 191 rcu_read_unlock();
192 netlink_table_ungrab();
191 goto out; 193 goto out;
192 } 194 }
193 } 195 }
194 rcu_read_unlock(); 196 rcu_read_unlock();
197 netlink_table_ungrab();
195 } else { 198 } else {
196 err = netlink_change_ngroups(init_net.genl_sock, 199 err = netlink_change_ngroups(init_net.genl_sock,
197 mc_groups_longs * BITS_PER_LONG); 200 mc_groups_longs * BITS_PER_LONG);
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c
index 2f65dcaed2fb..5f42f30dd168 100644
--- a/net/phonet/pn_dev.c
+++ b/net/phonet/pn_dev.c
@@ -209,7 +209,14 @@ static int phonet_device_autoconf(struct net_device *dev)
209 SIOCPNGAUTOCONF); 209 SIOCPNGAUTOCONF);
210 if (ret < 0) 210 if (ret < 0)
211 return ret; 211 return ret;
212 return phonet_address_add(dev, req.ifr_phonet_autoconf.device); 212
213 ASSERT_RTNL();
214 ret = phonet_address_add(dev, req.ifr_phonet_autoconf.device);
215 if (ret)
216 return ret;
217 phonet_address_notify(RTM_NEWADDR, dev,
218 req.ifr_phonet_autoconf.device);
219 return 0;
213} 220}
214 221
215/* notify Phonet of device events */ 222/* notify Phonet of device events */
diff --git a/net/rds/af_rds.c b/net/rds/af_rds.c
index 108ed2e671c5..6b58aeff4c7a 100644
--- a/net/rds/af_rds.c
+++ b/net/rds/af_rds.c
@@ -359,7 +359,7 @@ static struct proto rds_proto = {
359 .obj_size = sizeof(struct rds_sock), 359 .obj_size = sizeof(struct rds_sock),
360}; 360};
361 361
362static struct proto_ops rds_proto_ops = { 362static const struct proto_ops rds_proto_ops = {
363 .family = AF_RDS, 363 .family = AF_RDS,
364 .owner = THIS_MODULE, 364 .owner = THIS_MODULE,
365 .release = rds_release, 365 .release = rds_release,
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index e5f478ca3d61..1e166c9685aa 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -63,7 +63,7 @@ int sysctl_rose_window_size = ROSE_DEFAULT_WINDOW_SIZE;
63static HLIST_HEAD(rose_list); 63static HLIST_HEAD(rose_list);
64static DEFINE_SPINLOCK(rose_list_lock); 64static DEFINE_SPINLOCK(rose_list_lock);
65 65
66static struct proto_ops rose_proto_ops; 66static const struct proto_ops rose_proto_ops;
67 67
68ax25_address rose_callsign; 68ax25_address rose_callsign;
69 69
@@ -1515,7 +1515,7 @@ static struct net_proto_family rose_family_ops = {
1515 .owner = THIS_MODULE, 1515 .owner = THIS_MODULE,
1516}; 1516};
1517 1517
1518static struct proto_ops rose_proto_ops = { 1518static const struct proto_ops rose_proto_ops = {
1519 .family = PF_ROSE, 1519 .family = PF_ROSE,
1520 .owner = THIS_MODULE, 1520 .owner = THIS_MODULE,
1521 .release = rose_release, 1521 .release = rose_release,
diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
index c9f1f0a3a2ff..b4a220977031 100644
--- a/net/rxrpc/ar-ack.c
+++ b/net/rxrpc/ar-ack.c
@@ -40,7 +40,7 @@ static const s8 rxrpc_ack_priority[] = {
40/* 40/*
41 * propose an ACK be sent 41 * propose an ACK be sent
42 */ 42 */
43void __rxrpc_propose_ACK(struct rxrpc_call *call, uint8_t ack_reason, 43void __rxrpc_propose_ACK(struct rxrpc_call *call, u8 ack_reason,
44 __be32 serial, bool immediate) 44 __be32 serial, bool immediate)
45{ 45{
46 unsigned long expiry; 46 unsigned long expiry;
@@ -120,7 +120,7 @@ cancel_timer:
120/* 120/*
121 * propose an ACK be sent, locking the call structure 121 * propose an ACK be sent, locking the call structure
122 */ 122 */
123void rxrpc_propose_ACK(struct rxrpc_call *call, uint8_t ack_reason, 123void rxrpc_propose_ACK(struct rxrpc_call *call, u8 ack_reason,
124 __be32 serial, bool immediate) 124 __be32 serial, bool immediate)
125{ 125{
126 s8 prior = rxrpc_ack_priority[ack_reason]; 126 s8 prior = rxrpc_ack_priority[ack_reason];
@@ -520,7 +520,7 @@ static void rxrpc_zap_tx_window(struct rxrpc_call *call)
520 struct rxrpc_skb_priv *sp; 520 struct rxrpc_skb_priv *sp;
521 struct sk_buff *skb; 521 struct sk_buff *skb;
522 unsigned long _skb, *acks_window; 522 unsigned long _skb, *acks_window;
523 uint8_t winsz = call->acks_winsz; 523 u8 winsz = call->acks_winsz;
524 int tail; 524 int tail;
525 525
526 acks_window = call->acks_window; 526 acks_window = call->acks_window;
diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index 3e7318c1343c..7043b294bb67 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -229,7 +229,7 @@ struct rxrpc_conn_bundle {
229 int debug_id; /* debug ID for printks */ 229 int debug_id; /* debug ID for printks */
230 unsigned short num_conns; /* number of connections in this bundle */ 230 unsigned short num_conns; /* number of connections in this bundle */
231 __be16 service_id; /* service ID */ 231 __be16 service_id; /* service ID */
232 uint8_t security_ix; /* security type */ 232 u8 security_ix; /* security type */
233}; 233};
234 234
235/* 235/*
@@ -370,10 +370,10 @@ struct rxrpc_call {
370 u8 channel; /* connection channel occupied by this call */ 370 u8 channel; /* connection channel occupied by this call */
371 371
372 /* transmission-phase ACK management */ 372 /* transmission-phase ACK management */
373 uint8_t acks_head; /* offset into window of first entry */ 373 u8 acks_head; /* offset into window of first entry */
374 uint8_t acks_tail; /* offset into window of last entry */ 374 u8 acks_tail; /* offset into window of last entry */
375 uint8_t acks_winsz; /* size of un-ACK'd window */ 375 u8 acks_winsz; /* size of un-ACK'd window */
376 uint8_t acks_unacked; /* lowest unacked packet in last ACK received */ 376 u8 acks_unacked; /* lowest unacked packet in last ACK received */
377 int acks_latest; /* serial number of latest ACK received */ 377 int acks_latest; /* serial number of latest ACK received */
378 rxrpc_seq_t acks_hard; /* highest definitively ACK'd msg seq */ 378 rxrpc_seq_t acks_hard; /* highest definitively ACK'd msg seq */
379 unsigned long *acks_window; /* sent packet window 379 unsigned long *acks_window; /* sent packet window
@@ -388,7 +388,7 @@ struct rxrpc_call {
388 rxrpc_seq_t rx_first_oos; /* first packet in rx_oos_queue (or 0) */ 388 rxrpc_seq_t rx_first_oos; /* first packet in rx_oos_queue (or 0) */
389 rxrpc_seq_t ackr_win_top; /* top of ACK window (rx_data_eaten is bottom) */ 389 rxrpc_seq_t ackr_win_top; /* top of ACK window (rx_data_eaten is bottom) */
390 rxrpc_seq_net_t ackr_prev_seq; /* previous sequence number received */ 390 rxrpc_seq_net_t ackr_prev_seq; /* previous sequence number received */
391 uint8_t ackr_reason; /* reason to ACK */ 391 u8 ackr_reason; /* reason to ACK */
392 __be32 ackr_serial; /* serial of packet being ACK'd */ 392 __be32 ackr_serial; /* serial of packet being ACK'd */
393 atomic_t ackr_not_idle; /* number of packets in Rx queue */ 393 atomic_t ackr_not_idle; /* number of packets in Rx queue */
394 394
@@ -402,22 +402,6 @@ struct rxrpc_call {
402}; 402};
403 403
404/* 404/*
405 * RxRPC key for Kerberos (type-2 security)
406 */
407struct rxkad_key {
408 u16 security_index; /* RxRPC header security index */
409 u16 ticket_len; /* length of ticket[] */
410 u32 expiry; /* time at which expires */
411 u32 kvno; /* key version number */
412 u8 session_key[8]; /* DES session key */
413 u8 ticket[0]; /* the encrypted ticket */
414};
415
416struct rxrpc_key_payload {
417 struct rxkad_key k;
418};
419
420/*
421 * locally abort an RxRPC call 405 * locally abort an RxRPC call
422 */ 406 */
423static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code) 407static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
@@ -450,8 +434,8 @@ extern int rxrpc_reject_call(struct rxrpc_sock *);
450/* 434/*
451 * ar-ack.c 435 * ar-ack.c
452 */ 436 */
453extern void __rxrpc_propose_ACK(struct rxrpc_call *, uint8_t, __be32, bool); 437extern void __rxrpc_propose_ACK(struct rxrpc_call *, u8, __be32, bool);
454extern void rxrpc_propose_ACK(struct rxrpc_call *, uint8_t, __be32, bool); 438extern void rxrpc_propose_ACK(struct rxrpc_call *, u8, __be32, bool);
455extern void rxrpc_process_call(struct work_struct *); 439extern void rxrpc_process_call(struct work_struct *);
456 440
457/* 441/*
diff --git a/net/rxrpc/ar-key.c b/net/rxrpc/ar-key.c
index ad8c7a782da1..74697b200496 100644
--- a/net/rxrpc/ar-key.c
+++ b/net/rxrpc/ar-key.c
@@ -17,6 +17,7 @@
17#include <linux/skbuff.h> 17#include <linux/skbuff.h>
18#include <linux/key-type.h> 18#include <linux/key-type.h>
19#include <linux/crypto.h> 19#include <linux/crypto.h>
20#include <linux/ctype.h>
20#include <net/sock.h> 21#include <net/sock.h>
21#include <net/af_rxrpc.h> 22#include <net/af_rxrpc.h>
22#include <keys/rxrpc-type.h> 23#include <keys/rxrpc-type.h>
@@ -28,6 +29,7 @@ static int rxrpc_instantiate_s(struct key *, const void *, size_t);
28static void rxrpc_destroy(struct key *); 29static void rxrpc_destroy(struct key *);
29static void rxrpc_destroy_s(struct key *); 30static void rxrpc_destroy_s(struct key *);
30static void rxrpc_describe(const struct key *, struct seq_file *); 31static void rxrpc_describe(const struct key *, struct seq_file *);
32static long rxrpc_read(const struct key *, char __user *, size_t);
31 33
32/* 34/*
33 * rxrpc defined keys take an arbitrary string as the description and an 35 * rxrpc defined keys take an arbitrary string as the description and an
@@ -39,6 +41,7 @@ struct key_type key_type_rxrpc = {
39 .match = user_match, 41 .match = user_match,
40 .destroy = rxrpc_destroy, 42 .destroy = rxrpc_destroy,
41 .describe = rxrpc_describe, 43 .describe = rxrpc_describe,
44 .read = rxrpc_read,
42}; 45};
43EXPORT_SYMBOL(key_type_rxrpc); 46EXPORT_SYMBOL(key_type_rxrpc);
44 47
@@ -55,6 +58,595 @@ struct key_type key_type_rxrpc_s = {
55}; 58};
56 59
57/* 60/*
61 * parse an RxKAD type XDR format token
62 * - the caller guarantees we have at least 4 words
63 */
64static int rxrpc_instantiate_xdr_rxkad(struct key *key, const __be32 *xdr,
65 unsigned toklen)
66{
67 struct rxrpc_key_token *token, **pptoken;
68 size_t plen;
69 u32 tktlen;
70 int ret;
71
72 _enter(",{%x,%x,%x,%x},%u",
73 ntohl(xdr[0]), ntohl(xdr[1]), ntohl(xdr[2]), ntohl(xdr[3]),
74 toklen);
75
76 if (toklen <= 8 * 4)
77 return -EKEYREJECTED;
78 tktlen = ntohl(xdr[7]);
79 _debug("tktlen: %x", tktlen);
80 if (tktlen > AFSTOKEN_RK_TIX_MAX)
81 return -EKEYREJECTED;
82 if (8 * 4 + tktlen != toklen)
83 return -EKEYREJECTED;
84
85 plen = sizeof(*token) + sizeof(*token->kad) + tktlen;
86 ret = key_payload_reserve(key, key->datalen + plen);
87 if (ret < 0)
88 return ret;
89
90 plen -= sizeof(*token);
91 token = kmalloc(sizeof(*token), GFP_KERNEL);
92 if (!token)
93 return -ENOMEM;
94
95 token->kad = kmalloc(plen, GFP_KERNEL);
96 if (!token->kad) {
97 kfree(token);
98 return -ENOMEM;
99 }
100
101 token->security_index = RXRPC_SECURITY_RXKAD;
102 token->kad->ticket_len = tktlen;
103 token->kad->vice_id = ntohl(xdr[0]);
104 token->kad->kvno = ntohl(xdr[1]);
105 token->kad->start = ntohl(xdr[4]);
106 token->kad->expiry = ntohl(xdr[5]);
107 token->kad->primary_flag = ntohl(xdr[6]);
108 memcpy(&token->kad->session_key, &xdr[2], 8);
109 memcpy(&token->kad->ticket, &xdr[8], tktlen);
110
111 _debug("SCIX: %u", token->security_index);
112 _debug("TLEN: %u", token->kad->ticket_len);
113 _debug("EXPY: %x", token->kad->expiry);
114 _debug("KVNO: %u", token->kad->kvno);
115 _debug("PRIM: %u", token->kad->primary_flag);
116 _debug("SKEY: %02x%02x%02x%02x%02x%02x%02x%02x",
117 token->kad->session_key[0], token->kad->session_key[1],
118 token->kad->session_key[2], token->kad->session_key[3],
119 token->kad->session_key[4], token->kad->session_key[5],
120 token->kad->session_key[6], token->kad->session_key[7]);
121 if (token->kad->ticket_len >= 8)
122 _debug("TCKT: %02x%02x%02x%02x%02x%02x%02x%02x",
123 token->kad->ticket[0], token->kad->ticket[1],
124 token->kad->ticket[2], token->kad->ticket[3],
125 token->kad->ticket[4], token->kad->ticket[5],
126 token->kad->ticket[6], token->kad->ticket[7]);
127
128 /* count the number of tokens attached */
129 key->type_data.x[0]++;
130
131 /* attach the data */
132 for (pptoken = (struct rxrpc_key_token **)&key->payload.data;
133 *pptoken;
134 pptoken = &(*pptoken)->next)
135 continue;
136 *pptoken = token;
137 if (token->kad->expiry < key->expiry)
138 key->expiry = token->kad->expiry;
139
140 _leave(" = 0");
141 return 0;
142}
143
144static void rxrpc_free_krb5_principal(struct krb5_principal *princ)
145{
146 int loop;
147
148 if (princ->name_parts) {
149 for (loop = princ->n_name_parts - 1; loop >= 0; loop--)
150 kfree(princ->name_parts[loop]);
151 kfree(princ->name_parts);
152 }
153 kfree(princ->realm);
154}
155
156static void rxrpc_free_krb5_tagged(struct krb5_tagged_data *td)
157{
158 kfree(td->data);
159}
160
161/*
162 * free up an RxK5 token
163 */
164static void rxrpc_rxk5_free(struct rxk5_key *rxk5)
165{
166 int loop;
167
168 rxrpc_free_krb5_principal(&rxk5->client);
169 rxrpc_free_krb5_principal(&rxk5->server);
170 rxrpc_free_krb5_tagged(&rxk5->session);
171
172 if (rxk5->addresses) {
173 for (loop = rxk5->n_addresses - 1; loop >= 0; loop--)
174 rxrpc_free_krb5_tagged(&rxk5->addresses[loop]);
175 kfree(rxk5->addresses);
176 }
177 if (rxk5->authdata) {
178 for (loop = rxk5->n_authdata - 1; loop >= 0; loop--)
179 rxrpc_free_krb5_tagged(&rxk5->authdata[loop]);
180 kfree(rxk5->authdata);
181 }
182
183 kfree(rxk5->ticket);
184 kfree(rxk5->ticket2);
185 kfree(rxk5);
186}
187
188/*
189 * extract a krb5 principal
190 */
191static int rxrpc_krb5_decode_principal(struct krb5_principal *princ,
192 const __be32 **_xdr,
193 unsigned *_toklen)
194{
195 const __be32 *xdr = *_xdr;
196 unsigned toklen = *_toklen, n_parts, loop, tmp;
197
198 /* there must be at least one name, and at least #names+1 length
199 * words */
200 if (toklen <= 12)
201 return -EINVAL;
202
203 _enter(",{%x,%x,%x},%u",
204 ntohl(xdr[0]), ntohl(xdr[1]), ntohl(xdr[2]), toklen);
205
206 n_parts = ntohl(*xdr++);
207 toklen -= 4;
208 if (n_parts <= 0 || n_parts > AFSTOKEN_K5_COMPONENTS_MAX)
209 return -EINVAL;
210 princ->n_name_parts = n_parts;
211
212 if (toklen <= (n_parts + 1) * 4)
213 return -EINVAL;
214
215 princ->name_parts = kcalloc(sizeof(char *), n_parts, GFP_KERNEL);
216 if (!princ->name_parts)
217 return -ENOMEM;
218
219 for (loop = 0; loop < n_parts; loop++) {
220 if (toklen < 4)
221 return -EINVAL;
222 tmp = ntohl(*xdr++);
223 toklen -= 4;
224 if (tmp <= 0 || tmp > AFSTOKEN_STRING_MAX)
225 return -EINVAL;
226 if (tmp > toklen)
227 return -EINVAL;
228 princ->name_parts[loop] = kmalloc(tmp + 1, GFP_KERNEL);
229 if (!princ->name_parts[loop])
230 return -ENOMEM;
231 memcpy(princ->name_parts[loop], xdr, tmp);
232 princ->name_parts[loop][tmp] = 0;
233 tmp = (tmp + 3) & ~3;
234 toklen -= tmp;
235 xdr += tmp >> 2;
236 }
237
238 if (toklen < 4)
239 return -EINVAL;
240 tmp = ntohl(*xdr++);
241 toklen -= 4;
242 if (tmp <= 0 || tmp > AFSTOKEN_K5_REALM_MAX)
243 return -EINVAL;
244 if (tmp > toklen)
245 return -EINVAL;
246 princ->realm = kmalloc(tmp + 1, GFP_KERNEL);
247 if (!princ->realm)
248 return -ENOMEM;
249 memcpy(princ->realm, xdr, tmp);
250 princ->realm[tmp] = 0;
251 tmp = (tmp + 3) & ~3;
252 toklen -= tmp;
253 xdr += tmp >> 2;
254
255 _debug("%s/...@%s", princ->name_parts[0], princ->realm);
256
257 *_xdr = xdr;
258 *_toklen = toklen;
259 _leave(" = 0 [toklen=%u]", toklen);
260 return 0;
261}
262
263/*
264 * extract a piece of krb5 tagged data
265 */
266static int rxrpc_krb5_decode_tagged_data(struct krb5_tagged_data *td,
267 size_t max_data_size,
268 const __be32 **_xdr,
269 unsigned *_toklen)
270{
271 const __be32 *xdr = *_xdr;
272 unsigned toklen = *_toklen, len;
273
274 /* there must be at least one tag and one length word */
275 if (toklen <= 8)
276 return -EINVAL;
277
278 _enter(",%zu,{%x,%x},%u",
279 max_data_size, ntohl(xdr[0]), ntohl(xdr[1]), toklen);
280
281 td->tag = ntohl(*xdr++);
282 len = ntohl(*xdr++);
283 toklen -= 8;
284 if (len > max_data_size)
285 return -EINVAL;
286 td->data_len = len;
287
288 if (len > 0) {
289 td->data = kmalloc(len, GFP_KERNEL);
290 if (!td->data)
291 return -ENOMEM;
292 memcpy(td->data, xdr, len);
293 len = (len + 3) & ~3;
294 toklen -= len;
295 xdr += len >> 2;
296 }
297
298 _debug("tag %x len %x", td->tag, td->data_len);
299
300 *_xdr = xdr;
301 *_toklen = toklen;
302 _leave(" = 0 [toklen=%u]", toklen);
303 return 0;
304}
305
306/*
307 * extract an array of tagged data
308 */
309static int rxrpc_krb5_decode_tagged_array(struct krb5_tagged_data **_td,
310 u8 *_n_elem,
311 u8 max_n_elem,
312 size_t max_elem_size,
313 const __be32 **_xdr,
314 unsigned *_toklen)
315{
316 struct krb5_tagged_data *td;
317 const __be32 *xdr = *_xdr;
318 unsigned toklen = *_toklen, n_elem, loop;
319 int ret;
320
321 /* there must be at least one count */
322 if (toklen < 4)
323 return -EINVAL;
324
325 _enter(",,%u,%zu,{%x},%u",
326 max_n_elem, max_elem_size, ntohl(xdr[0]), toklen);
327
328 n_elem = ntohl(*xdr++);
329 toklen -= 4;
330 if (n_elem < 0 || n_elem > max_n_elem)
331 return -EINVAL;
332 *_n_elem = n_elem;
333 if (n_elem > 0) {
334 if (toklen <= (n_elem + 1) * 4)
335 return -EINVAL;
336
337 _debug("n_elem %d", n_elem);
338
339 td = kcalloc(sizeof(struct krb5_tagged_data), n_elem,
340 GFP_KERNEL);
341 if (!td)
342 return -ENOMEM;
343 *_td = td;
344
345 for (loop = 0; loop < n_elem; loop++) {
346 ret = rxrpc_krb5_decode_tagged_data(&td[loop],
347 max_elem_size,
348 &xdr, &toklen);
349 if (ret < 0)
350 return ret;
351 }
352 }
353
354 *_xdr = xdr;
355 *_toklen = toklen;
356 _leave(" = 0 [toklen=%u]", toklen);
357 return 0;
358}
359
360/*
361 * extract a krb5 ticket
362 */
363static int rxrpc_krb5_decode_ticket(u8 **_ticket, u16 *_tktlen,
364 const __be32 **_xdr, unsigned *_toklen)
365{
366 const __be32 *xdr = *_xdr;
367 unsigned toklen = *_toklen, len;
368
369 /* there must be at least one length word */
370 if (toklen <= 4)
371 return -EINVAL;
372
373 _enter(",{%x},%u", ntohl(xdr[0]), toklen);
374
375 len = ntohl(*xdr++);
376 toklen -= 4;
377 if (len > AFSTOKEN_K5_TIX_MAX)
378 return -EINVAL;
379 *_tktlen = len;
380
381 _debug("ticket len %u", len);
382
383 if (len > 0) {
384 *_ticket = kmalloc(len, GFP_KERNEL);
385 if (!*_ticket)
386 return -ENOMEM;
387 memcpy(*_ticket, xdr, len);
388 len = (len + 3) & ~3;
389 toklen -= len;
390 xdr += len >> 2;
391 }
392
393 *_xdr = xdr;
394 *_toklen = toklen;
395 _leave(" = 0 [toklen=%u]", toklen);
396 return 0;
397}
398
399/*
400 * parse an RxK5 type XDR format token
401 * - the caller guarantees we have at least 4 words
402 */
403static int rxrpc_instantiate_xdr_rxk5(struct key *key, const __be32 *xdr,
404 unsigned toklen)
405{
406 struct rxrpc_key_token *token, **pptoken;
407 struct rxk5_key *rxk5;
408 const __be32 *end_xdr = xdr + (toklen >> 2);
409 int ret;
410
411 _enter(",{%x,%x,%x,%x},%u",
412 ntohl(xdr[0]), ntohl(xdr[1]), ntohl(xdr[2]), ntohl(xdr[3]),
413 toklen);
414
415 /* reserve some payload space for this subkey - the length of the token
416 * is a reasonable approximation */
417 ret = key_payload_reserve(key, key->datalen + toklen);
418 if (ret < 0)
419 return ret;
420
421 token = kzalloc(sizeof(*token), GFP_KERNEL);
422 if (!token)
423 return -ENOMEM;
424
425 rxk5 = kzalloc(sizeof(*rxk5), GFP_KERNEL);
426 if (!rxk5) {
427 kfree(token);
428 return -ENOMEM;
429 }
430
431 token->security_index = RXRPC_SECURITY_RXK5;
432 token->k5 = rxk5;
433
434 /* extract the principals */
435 ret = rxrpc_krb5_decode_principal(&rxk5->client, &xdr, &toklen);
436 if (ret < 0)
437 goto error;
438 ret = rxrpc_krb5_decode_principal(&rxk5->server, &xdr, &toklen);
439 if (ret < 0)
440 goto error;
441
442 /* extract the session key and the encoding type (the tag field ->
443 * ENCTYPE_xxx) */
444 ret = rxrpc_krb5_decode_tagged_data(&rxk5->session, AFSTOKEN_DATA_MAX,
445 &xdr, &toklen);
446 if (ret < 0)
447 goto error;
448
449 if (toklen < 4 * 8 + 2 * 4)
450 goto inval;
451 rxk5->authtime = be64_to_cpup((const __be64 *) xdr);
452 xdr += 2;
453 rxk5->starttime = be64_to_cpup((const __be64 *) xdr);
454 xdr += 2;
455 rxk5->endtime = be64_to_cpup((const __be64 *) xdr);
456 xdr += 2;
457 rxk5->renew_till = be64_to_cpup((const __be64 *) xdr);
458 xdr += 2;
459 rxk5->is_skey = ntohl(*xdr++);
460 rxk5->flags = ntohl(*xdr++);
461 toklen -= 4 * 8 + 2 * 4;
462
463 _debug("times: a=%llx s=%llx e=%llx rt=%llx",
464 rxk5->authtime, rxk5->starttime, rxk5->endtime,
465 rxk5->renew_till);
466 _debug("is_skey=%x flags=%x", rxk5->is_skey, rxk5->flags);
467
468 /* extract the permitted client addresses */
469 ret = rxrpc_krb5_decode_tagged_array(&rxk5->addresses,
470 &rxk5->n_addresses,
471 AFSTOKEN_K5_ADDRESSES_MAX,
472 AFSTOKEN_DATA_MAX,
473 &xdr, &toklen);
474 if (ret < 0)
475 goto error;
476
477 ASSERTCMP((end_xdr - xdr) << 2, ==, toklen);
478
479 /* extract the tickets */
480 ret = rxrpc_krb5_decode_ticket(&rxk5->ticket, &rxk5->ticket_len,
481 &xdr, &toklen);
482 if (ret < 0)
483 goto error;
484 ret = rxrpc_krb5_decode_ticket(&rxk5->ticket2, &rxk5->ticket2_len,
485 &xdr, &toklen);
486 if (ret < 0)
487 goto error;
488
489 ASSERTCMP((end_xdr - xdr) << 2, ==, toklen);
490
491 /* extract the typed auth data */
492 ret = rxrpc_krb5_decode_tagged_array(&rxk5->authdata,
493 &rxk5->n_authdata,
494 AFSTOKEN_K5_AUTHDATA_MAX,
495 AFSTOKEN_BDATALN_MAX,
496 &xdr, &toklen);
497 if (ret < 0)
498 goto error;
499
500 ASSERTCMP((end_xdr - xdr) << 2, ==, toklen);
501
502 if (toklen != 0)
503 goto inval;
504
505 /* attach the payload to the key */
506 for (pptoken = (struct rxrpc_key_token **)&key->payload.data;
507 *pptoken;
508 pptoken = &(*pptoken)->next)
509 continue;
510 *pptoken = token;
511 if (token->kad->expiry < key->expiry)
512 key->expiry = token->kad->expiry;
513
514 _leave(" = 0");
515 return 0;
516
517inval:
518 ret = -EINVAL;
519error:
520 rxrpc_rxk5_free(rxk5);
521 kfree(token);
522 _leave(" = %d", ret);
523 return ret;
524}
525
526/*
527 * attempt to parse the data as the XDR format
528 * - the caller guarantees we have more than 7 words
529 */
530static int rxrpc_instantiate_xdr(struct key *key, const void *data, size_t datalen)
531{
532 const __be32 *xdr = data, *token;
533 const char *cp;
534 unsigned len, tmp, loop, ntoken, toklen, sec_ix;
535 int ret;
536
537 _enter(",{%x,%x,%x,%x},%zu",
538 ntohl(xdr[0]), ntohl(xdr[1]), ntohl(xdr[2]), ntohl(xdr[3]),
539 datalen);
540
541 if (datalen > AFSTOKEN_LENGTH_MAX)
542 goto not_xdr;
543
544 /* XDR is an array of __be32's */
545 if (datalen & 3)
546 goto not_xdr;
547
548 /* the flags should be 0 (the setpag bit must be handled by
549 * userspace) */
550 if (ntohl(*xdr++) != 0)
551 goto not_xdr;
552 datalen -= 4;
553
554 /* check the cell name */
555 len = ntohl(*xdr++);
556 if (len < 1 || len > AFSTOKEN_CELL_MAX)
557 goto not_xdr;
558 datalen -= 4;
559 tmp = (len + 3) & ~3;
560 if (tmp > datalen)
561 goto not_xdr;
562
563 cp = (const char *) xdr;
564 for (loop = 0; loop < len; loop++)
565 if (!isprint(cp[loop]))
566 goto not_xdr;
567 if (len < tmp)
568 for (; loop < tmp; loop++)
569 if (cp[loop])
570 goto not_xdr;
571 _debug("cellname: [%u/%u] '%*.*s'",
572 len, tmp, len, len, (const char *) xdr);
573 datalen -= tmp;
574 xdr += tmp >> 2;
575
576 /* get the token count */
577 if (datalen < 12)
578 goto not_xdr;
579 ntoken = ntohl(*xdr++);
580 datalen -= 4;
581 _debug("ntoken: %x", ntoken);
582 if (ntoken < 1 || ntoken > AFSTOKEN_MAX)
583 goto not_xdr;
584
585 /* check each token wrapper */
586 token = xdr;
587 loop = ntoken;
588 do {
589 if (datalen < 8)
590 goto not_xdr;
591 toklen = ntohl(*xdr++);
592 sec_ix = ntohl(*xdr);
593 datalen -= 4;
594 _debug("token: [%x/%zx] %x", toklen, datalen, sec_ix);
595 if (toklen < 20 || toklen > datalen)
596 goto not_xdr;
597 datalen -= (toklen + 3) & ~3;
598 xdr += (toklen + 3) >> 2;
599
600 } while (--loop > 0);
601
602 _debug("remainder: %zu", datalen);
603 if (datalen != 0)
604 goto not_xdr;
605
606 /* okay: we're going to assume it's valid XDR format
607 * - we ignore the cellname, relying on the key to be correctly named
608 */
609 do {
610 xdr = token;
611 toklen = ntohl(*xdr++);
612 token = xdr + ((toklen + 3) >> 2);
613 sec_ix = ntohl(*xdr++);
614 toklen -= 4;
615
616 _debug("TOKEN type=%u [%p-%p]", sec_ix, xdr, token);
617
618 switch (sec_ix) {
619 case RXRPC_SECURITY_RXKAD:
620 ret = rxrpc_instantiate_xdr_rxkad(key, xdr, toklen);
621 if (ret != 0)
622 goto error;
623 break;
624
625 case RXRPC_SECURITY_RXK5:
626 ret = rxrpc_instantiate_xdr_rxk5(key, xdr, toklen);
627 if (ret != 0)
628 goto error;
629 break;
630
631 default:
632 ret = -EPROTONOSUPPORT;
633 goto error;
634 }
635
636 } while (--ntoken > 0);
637
638 _leave(" = 0");
639 return 0;
640
641not_xdr:
642 _leave(" = -EPROTO");
643 return -EPROTO;
644error:
645 _leave(" = %d", ret);
646 return ret;
647}
648
649/*
58 * instantiate an rxrpc defined key 650 * instantiate an rxrpc defined key
59 * data should be of the form: 651 * data should be of the form:
60 * OFFSET LEN CONTENT 652 * OFFSET LEN CONTENT
@@ -70,8 +662,8 @@ struct key_type key_type_rxrpc_s = {
70 */ 662 */
71static int rxrpc_instantiate(struct key *key, const void *data, size_t datalen) 663static int rxrpc_instantiate(struct key *key, const void *data, size_t datalen)
72{ 664{
73 const struct rxkad_key *tsec; 665 const struct rxrpc_key_data_v1 *v1;
74 struct rxrpc_key_payload *upayload; 666 struct rxrpc_key_token *token, **pp;
75 size_t plen; 667 size_t plen;
76 u32 kver; 668 u32 kver;
77 int ret; 669 int ret;
@@ -82,6 +674,13 @@ static int rxrpc_instantiate(struct key *key, const void *data, size_t datalen)
82 if (!data && datalen == 0) 674 if (!data && datalen == 0)
83 return 0; 675 return 0;
84 676
677 /* determine if the XDR payload format is being used */
678 if (datalen > 7 * 4) {
679 ret = rxrpc_instantiate_xdr(key, data, datalen);
680 if (ret != -EPROTO)
681 return ret;
682 }
683
85 /* get the key interface version number */ 684 /* get the key interface version number */
86 ret = -EINVAL; 685 ret = -EINVAL;
87 if (datalen <= 4 || !data) 686 if (datalen <= 4 || !data)
@@ -98,53 +697,67 @@ static int rxrpc_instantiate(struct key *key, const void *data, size_t datalen)
98 697
99 /* deal with a version 1 key */ 698 /* deal with a version 1 key */
100 ret = -EINVAL; 699 ret = -EINVAL;
101 if (datalen < sizeof(*tsec)) 700 if (datalen < sizeof(*v1))
102 goto error; 701 goto error;
103 702
104 tsec = data; 703 v1 = data;
105 if (datalen != sizeof(*tsec) + tsec->ticket_len) 704 if (datalen != sizeof(*v1) + v1->ticket_length)
106 goto error; 705 goto error;
107 706
108 _debug("SCIX: %u", tsec->security_index); 707 _debug("SCIX: %u", v1->security_index);
109 _debug("TLEN: %u", tsec->ticket_len); 708 _debug("TLEN: %u", v1->ticket_length);
110 _debug("EXPY: %x", tsec->expiry); 709 _debug("EXPY: %x", v1->expiry);
111 _debug("KVNO: %u", tsec->kvno); 710 _debug("KVNO: %u", v1->kvno);
112 _debug("SKEY: %02x%02x%02x%02x%02x%02x%02x%02x", 711 _debug("SKEY: %02x%02x%02x%02x%02x%02x%02x%02x",
113 tsec->session_key[0], tsec->session_key[1], 712 v1->session_key[0], v1->session_key[1],
114 tsec->session_key[2], tsec->session_key[3], 713 v1->session_key[2], v1->session_key[3],
115 tsec->session_key[4], tsec->session_key[5], 714 v1->session_key[4], v1->session_key[5],
116 tsec->session_key[6], tsec->session_key[7]); 715 v1->session_key[6], v1->session_key[7]);
117 if (tsec->ticket_len >= 8) 716 if (v1->ticket_length >= 8)
118 _debug("TCKT: %02x%02x%02x%02x%02x%02x%02x%02x", 717 _debug("TCKT: %02x%02x%02x%02x%02x%02x%02x%02x",
119 tsec->ticket[0], tsec->ticket[1], 718 v1->ticket[0], v1->ticket[1],
120 tsec->ticket[2], tsec->ticket[3], 719 v1->ticket[2], v1->ticket[3],
121 tsec->ticket[4], tsec->ticket[5], 720 v1->ticket[4], v1->ticket[5],
122 tsec->ticket[6], tsec->ticket[7]); 721 v1->ticket[6], v1->ticket[7]);
123 722
124 ret = -EPROTONOSUPPORT; 723 ret = -EPROTONOSUPPORT;
125 if (tsec->security_index != 2) 724 if (v1->security_index != RXRPC_SECURITY_RXKAD)
126 goto error; 725 goto error;
127 726
128 key->type_data.x[0] = tsec->security_index; 727 plen = sizeof(*token->kad) + v1->ticket_length;
129 728 ret = key_payload_reserve(key, plen + sizeof(*token));
130 plen = sizeof(*upayload) + tsec->ticket_len;
131 ret = key_payload_reserve(key, plen);
132 if (ret < 0) 729 if (ret < 0)
133 goto error; 730 goto error;
134 731
135 ret = -ENOMEM; 732 ret = -ENOMEM;
136 upayload = kmalloc(plen, GFP_KERNEL); 733 token = kmalloc(sizeof(*token), GFP_KERNEL);
137 if (!upayload) 734 if (!token)
138 goto error; 735 goto error;
736 token->kad = kmalloc(plen, GFP_KERNEL);
737 if (!token->kad)
738 goto error_free;
739
740 token->security_index = RXRPC_SECURITY_RXKAD;
741 token->kad->ticket_len = v1->ticket_length;
742 token->kad->expiry = v1->expiry;
743 token->kad->kvno = v1->kvno;
744 memcpy(&token->kad->session_key, &v1->session_key, 8);
745 memcpy(&token->kad->ticket, v1->ticket, v1->ticket_length);
139 746
140 /* attach the data */ 747 /* attach the data */
141 memcpy(&upayload->k, tsec, sizeof(*tsec)); 748 key->type_data.x[0]++;
142 memcpy(&upayload->k.ticket, (void *)tsec + sizeof(*tsec), 749
143 tsec->ticket_len); 750 pp = (struct rxrpc_key_token **)&key->payload.data;
144 key->payload.data = upayload; 751 while (*pp)
145 key->expiry = tsec->expiry; 752 pp = &(*pp)->next;
753 *pp = token;
754 if (token->kad->expiry < key->expiry)
755 key->expiry = token->kad->expiry;
756 token = NULL;
146 ret = 0; 757 ret = 0;
147 758
759error_free:
760 kfree(token);
148error: 761error:
149 return ret; 762 return ret;
150} 763}
@@ -184,7 +797,26 @@ static int rxrpc_instantiate_s(struct key *key, const void *data,
184 */ 797 */
185static void rxrpc_destroy(struct key *key) 798static void rxrpc_destroy(struct key *key)
186{ 799{
187 kfree(key->payload.data); 800 struct rxrpc_key_token *token;
801
802 while ((token = key->payload.data)) {
803 key->payload.data = token->next;
804 switch (token->security_index) {
805 case RXRPC_SECURITY_RXKAD:
806 kfree(token->kad);
807 break;
808 case RXRPC_SECURITY_RXK5:
809 if (token->k5)
810 rxrpc_rxk5_free(token->k5);
811 break;
812 default:
813 printk(KERN_ERR "Unknown token type %x on rxrpc key\n",
814 token->security_index);
815 BUG();
816 }
817
818 kfree(token);
819 }
188} 820}
189 821
190/* 822/*
@@ -293,7 +925,7 @@ int rxrpc_get_server_data_key(struct rxrpc_connection *conn,
293 925
294 struct { 926 struct {
295 u32 kver; 927 u32 kver;
296 struct rxkad_key tsec; 928 struct rxrpc_key_data_v1 v1;
297 } data; 929 } data;
298 930
299 _enter(""); 931 _enter("");
@@ -308,13 +940,12 @@ int rxrpc_get_server_data_key(struct rxrpc_connection *conn,
308 _debug("key %d", key_serial(key)); 940 _debug("key %d", key_serial(key));
309 941
310 data.kver = 1; 942 data.kver = 1;
311 data.tsec.security_index = 2; 943 data.v1.security_index = RXRPC_SECURITY_RXKAD;
312 data.tsec.ticket_len = 0; 944 data.v1.ticket_length = 0;
313 data.tsec.expiry = expiry; 945 data.v1.expiry = expiry;
314 data.tsec.kvno = 0; 946 data.v1.kvno = 0;
315 947
316 memcpy(&data.tsec.session_key, session_key, 948 memcpy(&data.v1.session_key, session_key, sizeof(data.v1.session_key));
317 sizeof(data.tsec.session_key));
318 949
319 ret = key_instantiate_and_link(key, &data, sizeof(data), NULL, NULL); 950 ret = key_instantiate_and_link(key, &data, sizeof(data), NULL, NULL);
320 if (ret < 0) 951 if (ret < 0)
@@ -360,3 +991,210 @@ struct key *rxrpc_get_null_key(const char *keyname)
360 return key; 991 return key;
361} 992}
362EXPORT_SYMBOL(rxrpc_get_null_key); 993EXPORT_SYMBOL(rxrpc_get_null_key);
994
995/*
996 * read the contents of an rxrpc key
997 * - this returns the result in XDR form
998 */
999static long rxrpc_read(const struct key *key,
1000 char __user *buffer, size_t buflen)
1001{
1002 const struct rxrpc_key_token *token;
1003 const struct krb5_principal *princ;
1004 size_t size;
1005 __be32 __user *xdr, *oldxdr;
1006 u32 cnlen, toksize, ntoks, tok, zero;
1007 u16 toksizes[AFSTOKEN_MAX];
1008 int loop;
1009
1010 _enter("");
1011
1012 /* we don't know what form we should return non-AFS keys in */
1013 if (memcmp(key->description, "afs@", 4) != 0)
1014 return -EOPNOTSUPP;
1015 cnlen = strlen(key->description + 4);
1016
1017#define RND(X) (((X) + 3) & ~3)
1018
1019 /* AFS keys we return in XDR form, so we need to work out the size of
1020 * the XDR */
1021 size = 2 * 4; /* flags, cellname len */
1022 size += RND(cnlen); /* cellname */
1023 size += 1 * 4; /* token count */
1024
1025 ntoks = 0;
1026 for (token = key->payload.data; token; token = token->next) {
1027 toksize = 4; /* sec index */
1028
1029 switch (token->security_index) {
1030 case RXRPC_SECURITY_RXKAD:
1031 toksize += 8 * 4; /* viceid, kvno, key*2, begin,
1032 * end, primary, tktlen */
1033 toksize += RND(token->kad->ticket_len);
1034 break;
1035
1036 case RXRPC_SECURITY_RXK5:
1037 princ = &token->k5->client;
1038 toksize += 4 + princ->n_name_parts * 4;
1039 for (loop = 0; loop < princ->n_name_parts; loop++)
1040 toksize += RND(strlen(princ->name_parts[loop]));
1041 toksize += 4 + RND(strlen(princ->realm));
1042
1043 princ = &token->k5->server;
1044 toksize += 4 + princ->n_name_parts * 4;
1045 for (loop = 0; loop < princ->n_name_parts; loop++)
1046 toksize += RND(strlen(princ->name_parts[loop]));
1047 toksize += 4 + RND(strlen(princ->realm));
1048
1049 toksize += 8 + RND(token->k5->session.data_len);
1050
1051 toksize += 4 * 8 + 2 * 4;
1052
1053 toksize += 4 + token->k5->n_addresses * 8;
1054 for (loop = 0; loop < token->k5->n_addresses; loop++)
1055 toksize += RND(token->k5->addresses[loop].data_len);
1056
1057 toksize += 4 + RND(token->k5->ticket_len);
1058 toksize += 4 + RND(token->k5->ticket2_len);
1059
1060 toksize += 4 + token->k5->n_authdata * 8;
1061 for (loop = 0; loop < token->k5->n_authdata; loop++)
1062 toksize += RND(token->k5->authdata[loop].data_len);
1063 break;
1064
1065 default: /* we have a ticket we can't encode */
1066 BUG();
1067 continue;
1068 }
1069
1070 _debug("token[%u]: toksize=%u", ntoks, toksize);
1071 ASSERTCMP(toksize, <=, AFSTOKEN_LENGTH_MAX);
1072
1073 toksizes[ntoks++] = toksize;
1074 size += toksize + 4; /* each token has a length word */
1075 }
1076
1077#undef RND
1078
1079 if (!buffer || buflen < size)
1080 return size;
1081
1082 xdr = (__be32 __user *) buffer;
1083 zero = 0;
1084#define ENCODE(x) \
1085 do { \
1086 __be32 y = htonl(x); \
1087 if (put_user(y, xdr++) < 0) \
1088 goto fault; \
1089 } while(0)
1090#define ENCODE_DATA(l, s) \
1091 do { \
1092 u32 _l = (l); \
1093 ENCODE(l); \
1094 if (copy_to_user(xdr, (s), _l) != 0) \
1095 goto fault; \
1096 if (_l & 3 && \
1097 copy_to_user((u8 *)xdr + _l, &zero, 4 - (_l & 3)) != 0) \
1098 goto fault; \
1099 xdr += (_l + 3) >> 2; \
1100 } while(0)
1101#define ENCODE64(x) \
1102 do { \
1103 __be64 y = cpu_to_be64(x); \
1104 if (copy_to_user(xdr, &y, 8) != 0) \
1105 goto fault; \
1106 xdr += 8 >> 2; \
1107 } while(0)
1108#define ENCODE_STR(s) \
1109 do { \
1110 const char *_s = (s); \
1111 ENCODE_DATA(strlen(_s), _s); \
1112 } while(0)
1113
1114 ENCODE(0); /* flags */
1115 ENCODE_DATA(cnlen, key->description + 4); /* cellname */
1116 ENCODE(ntoks);
1117
1118 tok = 0;
1119 for (token = key->payload.data; token; token = token->next) {
1120 toksize = toksizes[tok++];
1121 ENCODE(toksize);
1122 oldxdr = xdr;
1123 ENCODE(token->security_index);
1124
1125 switch (token->security_index) {
1126 case RXRPC_SECURITY_RXKAD:
1127 ENCODE(token->kad->vice_id);
1128 ENCODE(token->kad->kvno);
1129 ENCODE_DATA(8, token->kad->session_key);
1130 ENCODE(token->kad->start);
1131 ENCODE(token->kad->expiry);
1132 ENCODE(token->kad->primary_flag);
1133 ENCODE_DATA(token->kad->ticket_len, token->kad->ticket);
1134 break;
1135
1136 case RXRPC_SECURITY_RXK5:
1137 princ = &token->k5->client;
1138 ENCODE(princ->n_name_parts);
1139 for (loop = 0; loop < princ->n_name_parts; loop++)
1140 ENCODE_STR(princ->name_parts[loop]);
1141 ENCODE_STR(princ->realm);
1142
1143 princ = &token->k5->server;
1144 ENCODE(princ->n_name_parts);
1145 for (loop = 0; loop < princ->n_name_parts; loop++)
1146 ENCODE_STR(princ->name_parts[loop]);
1147 ENCODE_STR(princ->realm);
1148
1149 ENCODE(token->k5->session.tag);
1150 ENCODE_DATA(token->k5->session.data_len,
1151 token->k5->session.data);
1152
1153 ENCODE64(token->k5->authtime);
1154 ENCODE64(token->k5->starttime);
1155 ENCODE64(token->k5->endtime);
1156 ENCODE64(token->k5->renew_till);
1157 ENCODE(token->k5->is_skey);
1158 ENCODE(token->k5->flags);
1159
1160 ENCODE(token->k5->n_addresses);
1161 for (loop = 0; loop < token->k5->n_addresses; loop++) {
1162 ENCODE(token->k5->addresses[loop].tag);
1163 ENCODE_DATA(token->k5->addresses[loop].data_len,
1164 token->k5->addresses[loop].data);
1165 }
1166
1167 ENCODE_DATA(token->k5->ticket_len, token->k5->ticket);
1168 ENCODE_DATA(token->k5->ticket2_len, token->k5->ticket2);
1169
1170 ENCODE(token->k5->n_authdata);
1171 for (loop = 0; loop < token->k5->n_authdata; loop++) {
1172 ENCODE(token->k5->authdata[loop].tag);
1173 ENCODE_DATA(token->k5->authdata[loop].data_len,
1174 token->k5->authdata[loop].data);
1175 }
1176 break;
1177
1178 default:
1179 BUG();
1180 break;
1181 }
1182
1183 ASSERTCMP((unsigned long)xdr - (unsigned long)oldxdr, ==,
1184 toksize);
1185 }
1186
1187#undef ENCODE_STR
1188#undef ENCODE_DATA
1189#undef ENCODE64
1190#undef ENCODE
1191
1192 ASSERTCMP(tok, ==, ntoks);
1193 ASSERTCMP((char __user *) xdr - buffer, ==, size);
1194 _leave(" = %zu", size);
1195 return size;
1196
1197fault:
1198 _leave(" = -EFAULT");
1199 return -EFAULT;
1200}
diff --git a/net/rxrpc/ar-security.c b/net/rxrpc/ar-security.c
index dc62920ee19a..49b3cc31ee1f 100644
--- a/net/rxrpc/ar-security.c
+++ b/net/rxrpc/ar-security.c
@@ -16,6 +16,7 @@
16#include <linux/crypto.h> 16#include <linux/crypto.h>
17#include <net/sock.h> 17#include <net/sock.h>
18#include <net/af_rxrpc.h> 18#include <net/af_rxrpc.h>
19#include <keys/rxrpc-type.h>
19#include "ar-internal.h" 20#include "ar-internal.h"
20 21
21static LIST_HEAD(rxrpc_security_methods); 22static LIST_HEAD(rxrpc_security_methods);
@@ -122,6 +123,7 @@ EXPORT_SYMBOL_GPL(rxrpc_unregister_security);
122 */ 123 */
123int rxrpc_init_client_conn_security(struct rxrpc_connection *conn) 124int rxrpc_init_client_conn_security(struct rxrpc_connection *conn)
124{ 125{
126 struct rxrpc_key_token *token;
125 struct rxrpc_security *sec; 127 struct rxrpc_security *sec;
126 struct key *key = conn->key; 128 struct key *key = conn->key;
127 int ret; 129 int ret;
@@ -135,7 +137,11 @@ int rxrpc_init_client_conn_security(struct rxrpc_connection *conn)
135 if (ret < 0) 137 if (ret < 0)
136 return ret; 138 return ret;
137 139
138 sec = rxrpc_security_lookup(key->type_data.x[0]); 140 if (!key->payload.data)
141 return -EKEYREJECTED;
142 token = key->payload.data;
143
144 sec = rxrpc_security_lookup(token->security_index);
139 if (!sec) 145 if (!sec)
140 return -EKEYREJECTED; 146 return -EKEYREJECTED;
141 conn->security = sec; 147 conn->security = sec;
diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
index ef8f91030a15..713ac593e2e9 100644
--- a/net/rxrpc/rxkad.c
+++ b/net/rxrpc/rxkad.c
@@ -18,6 +18,7 @@
18#include <linux/ctype.h> 18#include <linux/ctype.h>
19#include <net/sock.h> 19#include <net/sock.h>
20#include <net/af_rxrpc.h> 20#include <net/af_rxrpc.h>
21#include <keys/rxrpc-type.h>
21#define rxrpc_debug rxkad_debug 22#define rxrpc_debug rxkad_debug
22#include "ar-internal.h" 23#include "ar-internal.h"
23 24
@@ -42,7 +43,7 @@ struct rxkad_level2_hdr {
42 __be32 checksum; /* decrypted data checksum */ 43 __be32 checksum; /* decrypted data checksum */
43}; 44};
44 45
45MODULE_DESCRIPTION("RxRPC network protocol type-2 security (Kerberos)"); 46MODULE_DESCRIPTION("RxRPC network protocol type-2 security (Kerberos 4)");
46MODULE_AUTHOR("Red Hat, Inc."); 47MODULE_AUTHOR("Red Hat, Inc.");
47MODULE_LICENSE("GPL"); 48MODULE_LICENSE("GPL");
48 49
@@ -59,14 +60,14 @@ static DEFINE_MUTEX(rxkad_ci_mutex);
59 */ 60 */
60static int rxkad_init_connection_security(struct rxrpc_connection *conn) 61static int rxkad_init_connection_security(struct rxrpc_connection *conn)
61{ 62{
62 struct rxrpc_key_payload *payload;
63 struct crypto_blkcipher *ci; 63 struct crypto_blkcipher *ci;
64 struct rxrpc_key_token *token;
64 int ret; 65 int ret;
65 66
66 _enter("{%d},{%x}", conn->debug_id, key_serial(conn->key)); 67 _enter("{%d},{%x}", conn->debug_id, key_serial(conn->key));
67 68
68 payload = conn->key->payload.data; 69 token = conn->key->payload.data;
69 conn->security_ix = payload->k.security_index; 70 conn->security_ix = token->security_index;
70 71
71 ci = crypto_alloc_blkcipher("pcbc(fcrypt)", 0, CRYPTO_ALG_ASYNC); 72 ci = crypto_alloc_blkcipher("pcbc(fcrypt)", 0, CRYPTO_ALG_ASYNC);
72 if (IS_ERR(ci)) { 73 if (IS_ERR(ci)) {
@@ -75,8 +76,8 @@ static int rxkad_init_connection_security(struct rxrpc_connection *conn)
75 goto error; 76 goto error;
76 } 77 }
77 78
78 if (crypto_blkcipher_setkey(ci, payload->k.session_key, 79 if (crypto_blkcipher_setkey(ci, token->kad->session_key,
79 sizeof(payload->k.session_key)) < 0) 80 sizeof(token->kad->session_key)) < 0)
80 BUG(); 81 BUG();
81 82
82 switch (conn->security_level) { 83 switch (conn->security_level) {
@@ -110,7 +111,7 @@ error:
110 */ 111 */
111static void rxkad_prime_packet_security(struct rxrpc_connection *conn) 112static void rxkad_prime_packet_security(struct rxrpc_connection *conn)
112{ 113{
113 struct rxrpc_key_payload *payload; 114 struct rxrpc_key_token *token;
114 struct blkcipher_desc desc; 115 struct blkcipher_desc desc;
115 struct scatterlist sg[2]; 116 struct scatterlist sg[2];
116 struct rxrpc_crypt iv; 117 struct rxrpc_crypt iv;
@@ -123,8 +124,8 @@ static void rxkad_prime_packet_security(struct rxrpc_connection *conn)
123 if (!conn->key) 124 if (!conn->key)
124 return; 125 return;
125 126
126 payload = conn->key->payload.data; 127 token = conn->key->payload.data;
127 memcpy(&iv, payload->k.session_key, sizeof(iv)); 128 memcpy(&iv, token->kad->session_key, sizeof(iv));
128 129
129 desc.tfm = conn->cipher; 130 desc.tfm = conn->cipher;
130 desc.info = iv.x; 131 desc.info = iv.x;
@@ -197,7 +198,7 @@ static int rxkad_secure_packet_encrypt(const struct rxrpc_call *call,
197 u32 data_size, 198 u32 data_size,
198 void *sechdr) 199 void *sechdr)
199{ 200{
200 const struct rxrpc_key_payload *payload; 201 const struct rxrpc_key_token *token;
201 struct rxkad_level2_hdr rxkhdr 202 struct rxkad_level2_hdr rxkhdr
202 __attribute__((aligned(8))); /* must be all on one page */ 203 __attribute__((aligned(8))); /* must be all on one page */
203 struct rxrpc_skb_priv *sp; 204 struct rxrpc_skb_priv *sp;
@@ -219,8 +220,8 @@ static int rxkad_secure_packet_encrypt(const struct rxrpc_call *call,
219 rxkhdr.checksum = 0; 220 rxkhdr.checksum = 0;
220 221
221 /* encrypt from the session key */ 222 /* encrypt from the session key */
222 payload = call->conn->key->payload.data; 223 token = call->conn->key->payload.data;
223 memcpy(&iv, payload->k.session_key, sizeof(iv)); 224 memcpy(&iv, token->kad->session_key, sizeof(iv));
224 desc.tfm = call->conn->cipher; 225 desc.tfm = call->conn->cipher;
225 desc.info = iv.x; 226 desc.info = iv.x;
226 desc.flags = 0; 227 desc.flags = 0;
@@ -400,7 +401,7 @@ static int rxkad_verify_packet_encrypt(const struct rxrpc_call *call,
400 struct sk_buff *skb, 401 struct sk_buff *skb,
401 u32 *_abort_code) 402 u32 *_abort_code)
402{ 403{
403 const struct rxrpc_key_payload *payload; 404 const struct rxrpc_key_token *token;
404 struct rxkad_level2_hdr sechdr; 405 struct rxkad_level2_hdr sechdr;
405 struct rxrpc_skb_priv *sp; 406 struct rxrpc_skb_priv *sp;
406 struct blkcipher_desc desc; 407 struct blkcipher_desc desc;
@@ -431,8 +432,8 @@ static int rxkad_verify_packet_encrypt(const struct rxrpc_call *call,
431 skb_to_sgvec(skb, sg, 0, skb->len); 432 skb_to_sgvec(skb, sg, 0, skb->len);
432 433
433 /* decrypt from the session key */ 434 /* decrypt from the session key */
434 payload = call->conn->key->payload.data; 435 token = call->conn->key->payload.data;
435 memcpy(&iv, payload->k.session_key, sizeof(iv)); 436 memcpy(&iv, token->kad->session_key, sizeof(iv));
436 desc.tfm = call->conn->cipher; 437 desc.tfm = call->conn->cipher;
437 desc.info = iv.x; 438 desc.info = iv.x;
438 desc.flags = 0; 439 desc.flags = 0;
@@ -506,7 +507,7 @@ static int rxkad_verify_packet(const struct rxrpc_call *call,
506 if (!call->conn->cipher) 507 if (!call->conn->cipher)
507 return 0; 508 return 0;
508 509
509 if (sp->hdr.securityIndex != 2) { 510 if (sp->hdr.securityIndex != RXRPC_SECURITY_RXKAD) {
510 *_abort_code = RXKADINCONSISTENCY; 511 *_abort_code = RXKADINCONSISTENCY;
511 _leave(" = -EPROTO [not rxkad]"); 512 _leave(" = -EPROTO [not rxkad]");
512 return -EPROTO; 513 return -EPROTO;
@@ -737,7 +738,7 @@ static int rxkad_respond_to_challenge(struct rxrpc_connection *conn,
737 struct sk_buff *skb, 738 struct sk_buff *skb,
738 u32 *_abort_code) 739 u32 *_abort_code)
739{ 740{
740 const struct rxrpc_key_payload *payload; 741 const struct rxrpc_key_token *token;
741 struct rxkad_challenge challenge; 742 struct rxkad_challenge challenge;
742 struct rxkad_response resp 743 struct rxkad_response resp
743 __attribute__((aligned(8))); /* must be aligned for crypto */ 744 __attribute__((aligned(8))); /* must be aligned for crypto */
@@ -778,7 +779,7 @@ static int rxkad_respond_to_challenge(struct rxrpc_connection *conn,
778 if (conn->security_level < min_level) 779 if (conn->security_level < min_level)
779 goto protocol_error; 780 goto protocol_error;
780 781
781 payload = conn->key->payload.data; 782 token = conn->key->payload.data;
782 783
783 /* build the response packet */ 784 /* build the response packet */
784 memset(&resp, 0, sizeof(resp)); 785 memset(&resp, 0, sizeof(resp));
@@ -797,13 +798,13 @@ static int rxkad_respond_to_challenge(struct rxrpc_connection *conn,
797 (conn->channels[3] ? conn->channels[3]->call_id : 0); 798 (conn->channels[3] ? conn->channels[3]->call_id : 0);
798 resp.encrypted.inc_nonce = htonl(nonce + 1); 799 resp.encrypted.inc_nonce = htonl(nonce + 1);
799 resp.encrypted.level = htonl(conn->security_level); 800 resp.encrypted.level = htonl(conn->security_level);
800 resp.kvno = htonl(payload->k.kvno); 801 resp.kvno = htonl(token->kad->kvno);
801 resp.ticket_len = htonl(payload->k.ticket_len); 802 resp.ticket_len = htonl(token->kad->ticket_len);
802 803
803 /* calculate the response checksum and then do the encryption */ 804 /* calculate the response checksum and then do the encryption */
804 rxkad_calc_response_checksum(&resp); 805 rxkad_calc_response_checksum(&resp);
805 rxkad_encrypt_response(conn, &resp, &payload->k); 806 rxkad_encrypt_response(conn, &resp, token->kad);
806 return rxkad_send_response(conn, &sp->hdr, &resp, &payload->k); 807 return rxkad_send_response(conn, &sp->hdr, &resp, token->kad);
807 808
808protocol_error: 809protocol_error:
809 *_abort_code = abort_code; 810 *_abort_code = abort_code;
@@ -1122,7 +1123,7 @@ static void rxkad_clear(struct rxrpc_connection *conn)
1122static struct rxrpc_security rxkad = { 1123static struct rxrpc_security rxkad = {
1123 .owner = THIS_MODULE, 1124 .owner = THIS_MODULE,
1124 .name = "rxkad", 1125 .name = "rxkad",
1125 .security_index = RXKAD_VERSION, 1126 .security_index = RXRPC_SECURITY_RXKAD,
1126 .init_connection_security = rxkad_init_connection_security, 1127 .init_connection_security = rxkad_init_connection_security,
1127 .prime_packet_security = rxkad_prime_packet_security, 1128 .prime_packet_security = rxkad_prime_packet_security,
1128 .secure_packet = rxkad_secure_packet, 1129 .secure_packet = rxkad_secure_packet,
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 692d9a41cd23..903e4188b6ca 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -693,13 +693,18 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
693 if (new && i > 0) 693 if (new && i > 0)
694 atomic_inc(&new->refcnt); 694 atomic_inc(&new->refcnt);
695 695
696 qdisc_destroy(old); 696 if (!ingress)
697 qdisc_destroy(old);
697 } 698 }
698 699
699 notify_and_destroy(skb, n, classid, dev->qdisc, new); 700 if (!ingress) {
700 if (new && !new->ops->attach) 701 notify_and_destroy(skb, n, classid, dev->qdisc, new);
701 atomic_inc(&new->refcnt); 702 if (new && !new->ops->attach)
702 dev->qdisc = new ? : &noop_qdisc; 703 atomic_inc(&new->refcnt);
704 dev->qdisc = new ? : &noop_qdisc;
705 } else {
706 notify_and_destroy(skb, n, classid, old, new);
707 }
703 708
704 if (dev->flags & IFF_UP) 709 if (dev->flags & IFF_UP)
705 dev_activate(dev); 710 dev_activate(dev);
@@ -804,7 +809,7 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue,
804 stab = qdisc_get_stab(tca[TCA_STAB]); 809 stab = qdisc_get_stab(tca[TCA_STAB]);
805 if (IS_ERR(stab)) { 810 if (IS_ERR(stab)) {
806 err = PTR_ERR(stab); 811 err = PTR_ERR(stab);
807 goto err_out3; 812 goto err_out4;
808 } 813 }
809 sch->stab = stab; 814 sch->stab = stab;
810 } 815 }
@@ -833,7 +838,6 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue,
833 return sch; 838 return sch;
834 } 839 }
835err_out3: 840err_out3:
836 qdisc_put_stab(sch->stab);
837 dev_put(dev); 841 dev_put(dev);
838 kfree((char *) sch - sch->padded); 842 kfree((char *) sch - sch->padded);
839err_out2: 843err_out2:
@@ -847,6 +851,7 @@ err_out4:
847 * Any broken qdiscs that would require a ops->reset() here? 851 * Any broken qdiscs that would require a ops->reset() here?
848 * The qdisc was never in action so it shouldn't be necessary. 852 * The qdisc was never in action so it shouldn't be necessary.
849 */ 853 */
854 qdisc_put_stab(sch->stab);
850 if (ops->destroy) 855 if (ops->destroy)
851 ops->destroy(sch); 856 ops->destroy(sch);
852 goto err_out3; 857 goto err_out3;
@@ -1111,12 +1116,16 @@ create_n_graft:
1111 tcm->tcm_parent, tcm->tcm_parent, 1116 tcm->tcm_parent, tcm->tcm_parent,
1112 tca, &err); 1117 tca, &err);
1113 else { 1118 else {
1114 unsigned int ntx = 0; 1119 struct netdev_queue *dev_queue;
1115 1120
1116 if (p && p->ops->cl_ops && p->ops->cl_ops->select_queue) 1121 if (p && p->ops->cl_ops && p->ops->cl_ops->select_queue)
1117 ntx = p->ops->cl_ops->select_queue(p, tcm); 1122 dev_queue = p->ops->cl_ops->select_queue(p, tcm);
1123 else if (p)
1124 dev_queue = p->dev_queue;
1125 else
1126 dev_queue = netdev_get_tx_queue(dev, 0);
1118 1127
1119 q = qdisc_create(dev, netdev_get_tx_queue(dev, ntx), p, 1128 q = qdisc_create(dev, dev_queue, p,
1120 tcm->tcm_parent, tcm->tcm_handle, 1129 tcm->tcm_parent, tcm->tcm_handle,
1121 tca, &err); 1130 tca, &err);
1122 } 1131 }
diff --git a/net/sched/sch_drr.c b/net/sched/sch_drr.c
index 12b2fb04b29b..5a888af7e5da 100644
--- a/net/sched/sch_drr.c
+++ b/net/sched/sch_drr.c
@@ -274,8 +274,10 @@ static int drr_dump_class_stats(struct Qdisc *sch, unsigned long arg,
274 struct tc_drr_stats xstats; 274 struct tc_drr_stats xstats;
275 275
276 memset(&xstats, 0, sizeof(xstats)); 276 memset(&xstats, 0, sizeof(xstats));
277 if (cl->qdisc->q.qlen) 277 if (cl->qdisc->q.qlen) {
278 xstats.deficit = cl->deficit; 278 xstats.deficit = cl->deficit;
279 cl->qdisc->qstats.qlen = cl->qdisc->q.qlen;
280 }
279 281
280 if (gnet_stats_copy_basic(d, &cl->bstats) < 0 || 282 if (gnet_stats_copy_basic(d, &cl->bstats) < 0 ||
281 gnet_stats_copy_rate_est(d, &cl->rate_est) < 0 || 283 gnet_stats_copy_rate_est(d, &cl->rate_est) < 0 ||
diff --git a/net/sched/sch_mq.c b/net/sched/sch_mq.c
index dd5ee022f1f7..d1dea3d5dc92 100644
--- a/net/sched/sch_mq.c
+++ b/net/sched/sch_mq.c
@@ -125,13 +125,18 @@ static struct netdev_queue *mq_queue_get(struct Qdisc *sch, unsigned long cl)
125 return netdev_get_tx_queue(dev, ntx); 125 return netdev_get_tx_queue(dev, ntx);
126} 126}
127 127
128static unsigned int mq_select_queue(struct Qdisc *sch, struct tcmsg *tcm) 128static struct netdev_queue *mq_select_queue(struct Qdisc *sch,
129 struct tcmsg *tcm)
129{ 130{
130 unsigned int ntx = TC_H_MIN(tcm->tcm_parent); 131 unsigned int ntx = TC_H_MIN(tcm->tcm_parent);
132 struct netdev_queue *dev_queue = mq_queue_get(sch, ntx);
131 133
132 if (!mq_queue_get(sch, ntx)) 134 if (!dev_queue) {
133 return 0; 135 struct net_device *dev = qdisc_dev(sch);
134 return ntx - 1; 136
137 return netdev_get_tx_queue(dev, 0);
138 }
139 return dev_queue;
135} 140}
136 141
137static int mq_graft(struct Qdisc *sch, unsigned long cl, struct Qdisc *new, 142static int mq_graft(struct Qdisc *sch, unsigned long cl, struct Qdisc *new,
@@ -188,6 +193,7 @@ static int mq_dump_class_stats(struct Qdisc *sch, unsigned long cl,
188 struct netdev_queue *dev_queue = mq_queue_get(sch, cl); 193 struct netdev_queue *dev_queue = mq_queue_get(sch, cl);
189 194
190 sch = dev_queue->qdisc_sleeping; 195 sch = dev_queue->qdisc_sleeping;
196 sch->qstats.qlen = sch->q.qlen;
191 if (gnet_stats_copy_basic(d, &sch->bstats) < 0 || 197 if (gnet_stats_copy_basic(d, &sch->bstats) < 0 ||
192 gnet_stats_copy_queue(d, &sch->qstats) < 0) 198 gnet_stats_copy_queue(d, &sch->qstats) < 0)
193 return -1; 199 return -1;
diff --git a/net/sched/sch_multiq.c b/net/sched/sch_multiq.c
index 069f81c97277..7db2c88ce585 100644
--- a/net/sched/sch_multiq.c
+++ b/net/sched/sch_multiq.c
@@ -359,6 +359,7 @@ static int multiq_dump_class_stats(struct Qdisc *sch, unsigned long cl,
359 struct Qdisc *cl_q; 359 struct Qdisc *cl_q;
360 360
361 cl_q = q->queues[cl - 1]; 361 cl_q = q->queues[cl - 1];
362 cl_q->qstats.qlen = cl_q->q.qlen;
362 if (gnet_stats_copy_basic(d, &cl_q->bstats) < 0 || 363 if (gnet_stats_copy_basic(d, &cl_q->bstats) < 0 ||
363 gnet_stats_copy_queue(d, &cl_q->qstats) < 0) 364 gnet_stats_copy_queue(d, &cl_q->qstats) < 0)
364 return -1; 365 return -1;
diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c
index 0f73c412d04b..93285cecb246 100644
--- a/net/sched/sch_prio.c
+++ b/net/sched/sch_prio.c
@@ -322,6 +322,7 @@ static int prio_dump_class_stats(struct Qdisc *sch, unsigned long cl,
322 struct Qdisc *cl_q; 322 struct Qdisc *cl_q;
323 323
324 cl_q = q->queues[cl - 1]; 324 cl_q = q->queues[cl - 1];
325 cl_q->qstats.qlen = cl_q->q.qlen;
325 if (gnet_stats_copy_basic(d, &cl_q->bstats) < 0 || 326 if (gnet_stats_copy_basic(d, &cl_q->bstats) < 0 ||
326 gnet_stats_copy_queue(d, &cl_q->qstats) < 0) 327 gnet_stats_copy_queue(d, &cl_q->qstats) < 0)
327 return -1; 328 return -1;
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 6a4b19094143..bb280e60e00a 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -949,7 +949,7 @@ static int sctp6_rcv(struct sk_buff *skb)
949 return sctp_rcv(skb) ? -1 : 0; 949 return sctp_rcv(skb) ? -1 : 0;
950} 950}
951 951
952static struct inet6_protocol sctpv6_protocol = { 952static const struct inet6_protocol sctpv6_protocol = {
953 .handler = sctp6_rcv, 953 .handler = sctp6_rcv,
954 .err_handler = sctp_v6_err, 954 .err_handler = sctp_v6_err,
955 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL, 955 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 60093be8385d..c557f1fb1c66 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -924,7 +924,7 @@ static struct inet_protosw sctp_stream_protosw = {
924}; 924};
925 925
926/* Register with IP layer. */ 926/* Register with IP layer. */
927static struct net_protocol sctp_protocol = { 927static const struct net_protocol sctp_protocol = {
928 .handler = sctp_rcv, 928 .handler = sctp_rcv,
929 .err_handler = sctp_v4_err, 929 .err_handler = sctp_v4_err,
930 .no_policy = 1, 930 .no_policy = 1,
diff --git a/net/socket.c b/net/socket.c
index 6d4716559047..2a022c00d85c 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -489,6 +489,7 @@ static struct socket *sock_alloc(void)
489 489
490 sock = SOCKET_I(inode); 490 sock = SOCKET_I(inode);
491 491
492 kmemcheck_annotate_bitfield(sock, type);
492 inode->i_mode = S_IFSOCK | S_IRWXUGO; 493 inode->i_mode = S_IFSOCK | S_IRWXUGO;
493 inode->i_uid = current_fsuid(); 494 inode->i_uid = current_fsuid();
494 inode->i_gid = current_fsgid(); 495 inode->i_gid = current_fsgid();
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 4c210c2debc6..e5f92ee758f4 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -662,7 +662,7 @@ int cfg80211_wext_siwscan(struct net_device *dev,
662 int k; 662 int k;
663 int wiphy_freq = wiphy->bands[band]->channels[j].center_freq; 663 int wiphy_freq = wiphy->bands[band]->channels[j].center_freq;
664 for (k = 0; k < wreq->num_channels; k++) { 664 for (k = 0; k < wreq->num_channels; k++) {
665 int wext_freq = wreq->channel_list[k].m / 100000; 665 int wext_freq = cfg80211_wext_freq(wiphy, &wreq->channel_list[k]);
666 if (wext_freq == wiphy_freq) 666 if (wext_freq == wiphy_freq)
667 goto wext_freq_found; 667 goto wext_freq_found;
668 } 668 }
@@ -675,6 +675,11 @@ int cfg80211_wext_siwscan(struct net_device *dev,
675 wext_freq_not_found: ; 675 wext_freq_not_found: ;
676 } 676 }
677 } 677 }
678 /* No channels found? */
679 if (!i) {
680 err = -EINVAL;
681 goto out;
682 }
678 683
679 /* Set real number of channels specified in creq->channels[] */ 684 /* Set real number of channels specified in creq->channels[] */
680 creq->n_channels = i; 685 creq->n_channels = i;
diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index 68307883ec87..7fae7eee65de 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -188,7 +188,7 @@ void cfg80211_conn_work(struct work_struct *work)
188 rtnl_unlock(); 188 rtnl_unlock();
189} 189}
190 190
191static bool cfg80211_get_conn_bss(struct wireless_dev *wdev) 191static struct cfg80211_bss *cfg80211_get_conn_bss(struct wireless_dev *wdev)
192{ 192{
193 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); 193 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
194 struct cfg80211_bss *bss; 194 struct cfg80211_bss *bss;
@@ -205,7 +205,7 @@ static bool cfg80211_get_conn_bss(struct wireless_dev *wdev)
205 WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_PRIVACY, 205 WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_PRIVACY,
206 capa); 206 capa);
207 if (!bss) 207 if (!bss)
208 return false; 208 return NULL;
209 209
210 memcpy(wdev->conn->bssid, bss->bssid, ETH_ALEN); 210 memcpy(wdev->conn->bssid, bss->bssid, ETH_ALEN);
211 wdev->conn->params.bssid = wdev->conn->bssid; 211 wdev->conn->params.bssid = wdev->conn->bssid;
@@ -213,14 +213,14 @@ static bool cfg80211_get_conn_bss(struct wireless_dev *wdev)
213 wdev->conn->state = CFG80211_CONN_AUTHENTICATE_NEXT; 213 wdev->conn->state = CFG80211_CONN_AUTHENTICATE_NEXT;
214 schedule_work(&rdev->conn_work); 214 schedule_work(&rdev->conn_work);
215 215
216 cfg80211_put_bss(bss); 216 return bss;
217 return true;
218} 217}
219 218
220static void __cfg80211_sme_scan_done(struct net_device *dev) 219static void __cfg80211_sme_scan_done(struct net_device *dev)
221{ 220{
222 struct wireless_dev *wdev = dev->ieee80211_ptr; 221 struct wireless_dev *wdev = dev->ieee80211_ptr;
223 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); 222 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
223 struct cfg80211_bss *bss;
224 224
225 ASSERT_WDEV_LOCK(wdev); 225 ASSERT_WDEV_LOCK(wdev);
226 226
@@ -234,7 +234,10 @@ static void __cfg80211_sme_scan_done(struct net_device *dev)
234 wdev->conn->state != CFG80211_CONN_SCAN_AGAIN) 234 wdev->conn->state != CFG80211_CONN_SCAN_AGAIN)
235 return; 235 return;
236 236
237 if (!cfg80211_get_conn_bss(wdev)) { 237 bss = cfg80211_get_conn_bss(wdev);
238 if (bss) {
239 cfg80211_put_bss(bss);
240 } else {
238 /* not found */ 241 /* not found */
239 if (wdev->conn->state == CFG80211_CONN_SCAN_AGAIN) 242 if (wdev->conn->state == CFG80211_CONN_SCAN_AGAIN)
240 schedule_work(&rdev->conn_work); 243 schedule_work(&rdev->conn_work);
@@ -670,6 +673,7 @@ int __cfg80211_connect(struct cfg80211_registered_device *rdev,
670{ 673{
671 struct wireless_dev *wdev = dev->ieee80211_ptr; 674 struct wireless_dev *wdev = dev->ieee80211_ptr;
672 struct ieee80211_channel *chan; 675 struct ieee80211_channel *chan;
676 struct cfg80211_bss *bss = NULL;
673 int err; 677 int err;
674 678
675 ASSERT_WDEV_LOCK(wdev); 679 ASSERT_WDEV_LOCK(wdev);
@@ -760,7 +764,7 @@ int __cfg80211_connect(struct cfg80211_registered_device *rdev,
760 764
761 /* don't care about result -- but fill bssid & channel */ 765 /* don't care about result -- but fill bssid & channel */
762 if (!wdev->conn->params.bssid || !wdev->conn->params.channel) 766 if (!wdev->conn->params.bssid || !wdev->conn->params.channel)
763 cfg80211_get_conn_bss(wdev); 767 bss = cfg80211_get_conn_bss(wdev);
764 768
765 wdev->sme_state = CFG80211_SME_CONNECTING; 769 wdev->sme_state = CFG80211_SME_CONNECTING;
766 wdev->connect_keys = connkeys; 770 wdev->connect_keys = connkeys;
@@ -770,10 +774,11 @@ int __cfg80211_connect(struct cfg80211_registered_device *rdev,
770 wdev->conn->prev_bssid_valid = true; 774 wdev->conn->prev_bssid_valid = true;
771 } 775 }
772 776
773 /* we're good if we have both BSSID and channel */ 777 /* we're good if we have a matching bss struct */
774 if (wdev->conn->params.bssid && wdev->conn->params.channel) { 778 if (bss) {
775 wdev->conn->state = CFG80211_CONN_AUTHENTICATE_NEXT; 779 wdev->conn->state = CFG80211_CONN_AUTHENTICATE_NEXT;
776 err = cfg80211_conn_do_work(wdev); 780 err = cfg80211_conn_do_work(wdev);
781 cfg80211_put_bss(bss);
777 } else { 782 } else {
778 /* otherwise we'll need to scan for the AP first */ 783 /* otherwise we'll need to scan for the AP first */
779 err = cfg80211_conn_scan(wdev); 784 err = cfg80211_conn_scan(wdev);