diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2007-12-18 19:31:26 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:09:36 -0500 |
commit | 32bfd35d4b63bd63de4bb0d791ef049c3c868726 (patch) | |
tree | c1c213a35a00bcbe71a2ecc6521e19dec66cf6eb /net/mac80211/tx.c | |
parent | f653211197f3841f383fa9757ef8ce182c6cf627 (diff) |
mac80211: dont use interface indices in drivers
This patch gets rid of the if_id stuff where possible in favour of
a new per-virtual-interface structure "struct ieee80211_vif". This
structure is located at the end of the per-interface structure and
contains a variable length driver-use data area.
This has two advantages:
* removes the need to look up interfaces by if_id, this is better
for working with network namespaces and performance
* allows drivers to store and retrieve per-interface data without
having to allocate own lists/hash tables
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/tx.c')
-rw-r--r-- | net/mac80211/tx.c | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index f6194167253d..1b772ee2fe14 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
@@ -999,9 +999,7 @@ __ieee80211_tx_prepare(struct ieee80211_txrx_data *tx, | |||
999 | return TXRX_CONTINUE; | 999 | return TXRX_CONTINUE; |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | /* Device in tx->dev has a reference added; use dev_put(tx->dev) when | 1002 | /* |
1003 | * finished with it. | ||
1004 | * | ||
1005 | * NB: @tx is uninitialised when passed in here | 1003 | * NB: @tx is uninitialised when passed in here |
1006 | */ | 1004 | */ |
1007 | static int ieee80211_tx_prepare(struct ieee80211_txrx_data *tx, | 1005 | static int ieee80211_tx_prepare(struct ieee80211_txrx_data *tx, |
@@ -1022,6 +1020,7 @@ static int ieee80211_tx_prepare(struct ieee80211_txrx_data *tx, | |||
1022 | return -ENODEV; | 1020 | return -ENODEV; |
1023 | /* initialises tx with control */ | 1021 | /* initialises tx with control */ |
1024 | __ieee80211_tx_prepare(tx, skb, dev, control); | 1022 | __ieee80211_tx_prepare(tx, skb, dev, control); |
1023 | dev_put(dev); | ||
1025 | return 0; | 1024 | return 0; |
1026 | } | 1025 | } |
1027 | 1026 | ||
@@ -1252,7 +1251,7 @@ int ieee80211_master_start_xmit(struct sk_buff *skb, | |||
1252 | } | 1251 | } |
1253 | } | 1252 | } |
1254 | 1253 | ||
1255 | control.ifindex = odev->ifindex; | 1254 | control.vif = &osdata->vif; |
1256 | control.type = osdata->type; | 1255 | control.type = osdata->type; |
1257 | if (pkt_data->flags & IEEE80211_TXPD_REQ_TX_STATUS) | 1256 | if (pkt_data->flags & IEEE80211_TXPD_REQ_TX_STATUS) |
1258 | control.flags |= IEEE80211_TXCTL_REQ_TX_STATUS; | 1257 | control.flags |= IEEE80211_TXCTL_REQ_TX_STATUS; |
@@ -1691,7 +1690,8 @@ static void ieee80211_beacon_add_tim(struct ieee80211_local *local, | |||
1691 | read_unlock_bh(&local->sta_lock); | 1690 | read_unlock_bh(&local->sta_lock); |
1692 | } | 1691 | } |
1693 | 1692 | ||
1694 | struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, int if_id, | 1693 | struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, |
1694 | struct ieee80211_vif *vif, | ||
1695 | struct ieee80211_tx_control *control) | 1695 | struct ieee80211_tx_control *control) |
1696 | { | 1696 | { |
1697 | struct ieee80211_local *local = hw_to_local(hw); | 1697 | struct ieee80211_local *local = hw_to_local(hw); |
@@ -1703,19 +1703,16 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, int if_id, | |||
1703 | u8 *b_head, *b_tail; | 1703 | u8 *b_head, *b_tail; |
1704 | int bh_len, bt_len; | 1704 | int bh_len, bt_len; |
1705 | 1705 | ||
1706 | bdev = dev_get_by_index(&init_net, if_id); | 1706 | sdata = vif_to_sdata(vif); |
1707 | if (bdev) { | 1707 | bdev = sdata->dev; |
1708 | sdata = IEEE80211_DEV_TO_SUB_IF(bdev); | 1708 | ap = &sdata->u.ap; |
1709 | ap = &sdata->u.ap; | ||
1710 | dev_put(bdev); | ||
1711 | } | ||
1712 | 1709 | ||
1713 | if (!ap || sdata->type != IEEE80211_IF_TYPE_AP || | 1710 | if (!ap || sdata->type != IEEE80211_IF_TYPE_AP || |
1714 | !ap->beacon_head) { | 1711 | !ap->beacon_head) { |
1715 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 1712 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
1716 | if (net_ratelimit()) | 1713 | if (net_ratelimit()) |
1717 | printk(KERN_DEBUG "no beacon data avail for idx=%d " | 1714 | printk(KERN_DEBUG "no beacon data avail for %s\n", |
1718 | "(%s)\n", if_id, bdev ? bdev->name : "N/A"); | 1715 | bdev->name); |
1719 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ | 1716 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ |
1720 | return NULL; | 1717 | return NULL; |
1721 | } | 1718 | } |
@@ -1771,7 +1768,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, int if_id, | |||
1771 | } | 1768 | } |
1772 | EXPORT_SYMBOL(ieee80211_beacon_get); | 1769 | EXPORT_SYMBOL(ieee80211_beacon_get); |
1773 | 1770 | ||
1774 | void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id, | 1771 | void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
1775 | const void *frame, size_t frame_len, | 1772 | const void *frame, size_t frame_len, |
1776 | const struct ieee80211_tx_control *frame_txctl, | 1773 | const struct ieee80211_tx_control *frame_txctl, |
1777 | struct ieee80211_rts *rts) | 1774 | struct ieee80211_rts *rts) |
@@ -1781,13 +1778,14 @@ void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id, | |||
1781 | 1778 | ||
1782 | fctl = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS; | 1779 | fctl = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS; |
1783 | rts->frame_control = cpu_to_le16(fctl); | 1780 | rts->frame_control = cpu_to_le16(fctl); |
1784 | rts->duration = ieee80211_rts_duration(hw, if_id, frame_len, frame_txctl); | 1781 | rts->duration = ieee80211_rts_duration(hw, vif, frame_len, |
1782 | frame_txctl); | ||
1785 | memcpy(rts->ra, hdr->addr1, sizeof(rts->ra)); | 1783 | memcpy(rts->ra, hdr->addr1, sizeof(rts->ra)); |
1786 | memcpy(rts->ta, hdr->addr2, sizeof(rts->ta)); | 1784 | memcpy(rts->ta, hdr->addr2, sizeof(rts->ta)); |
1787 | } | 1785 | } |
1788 | EXPORT_SYMBOL(ieee80211_rts_get); | 1786 | EXPORT_SYMBOL(ieee80211_rts_get); |
1789 | 1787 | ||
1790 | void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id, | 1788 | void ieee80211_ctstoself_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
1791 | const void *frame, size_t frame_len, | 1789 | const void *frame, size_t frame_len, |
1792 | const struct ieee80211_tx_control *frame_txctl, | 1790 | const struct ieee80211_tx_control *frame_txctl, |
1793 | struct ieee80211_cts *cts) | 1791 | struct ieee80211_cts *cts) |
@@ -1797,13 +1795,15 @@ void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id, | |||
1797 | 1795 | ||
1798 | fctl = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS; | 1796 | fctl = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS; |
1799 | cts->frame_control = cpu_to_le16(fctl); | 1797 | cts->frame_control = cpu_to_le16(fctl); |
1800 | cts->duration = ieee80211_ctstoself_duration(hw, if_id, frame_len, frame_txctl); | 1798 | cts->duration = ieee80211_ctstoself_duration(hw, vif, |
1799 | frame_len, frame_txctl); | ||
1801 | memcpy(cts->ra, hdr->addr1, sizeof(cts->ra)); | 1800 | memcpy(cts->ra, hdr->addr1, sizeof(cts->ra)); |
1802 | } | 1801 | } |
1803 | EXPORT_SYMBOL(ieee80211_ctstoself_get); | 1802 | EXPORT_SYMBOL(ieee80211_ctstoself_get); |
1804 | 1803 | ||
1805 | struct sk_buff * | 1804 | struct sk_buff * |
1806 | ieee80211_get_buffered_bc(struct ieee80211_hw *hw, int if_id, | 1805 | ieee80211_get_buffered_bc(struct ieee80211_hw *hw, |
1806 | struct ieee80211_vif *vif, | ||
1807 | struct ieee80211_tx_control *control) | 1807 | struct ieee80211_tx_control *control) |
1808 | { | 1808 | { |
1809 | struct ieee80211_local *local = hw_to_local(hw); | 1809 | struct ieee80211_local *local = hw_to_local(hw); |
@@ -1816,12 +1816,9 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, int if_id, | |||
1816 | struct ieee80211_sub_if_data *sdata; | 1816 | struct ieee80211_sub_if_data *sdata; |
1817 | struct ieee80211_if_ap *bss = NULL; | 1817 | struct ieee80211_if_ap *bss = NULL; |
1818 | 1818 | ||
1819 | bdev = dev_get_by_index(&init_net, if_id); | 1819 | sdata = vif_to_sdata(vif); |
1820 | if (bdev) { | 1820 | bdev = sdata->dev; |
1821 | sdata = IEEE80211_DEV_TO_SUB_IF(bdev); | 1821 | |
1822 | bss = &sdata->u.ap; | ||
1823 | dev_put(bdev); | ||
1824 | } | ||
1825 | if (!bss || sdata->type != IEEE80211_IF_TYPE_AP || !bss->beacon_head) | 1822 | if (!bss || sdata->type != IEEE80211_IF_TYPE_AP || !bss->beacon_head) |
1826 | return NULL; | 1823 | return NULL; |
1827 | 1824 | ||
@@ -1857,7 +1854,6 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, int if_id, | |||
1857 | if (res == TXRX_DROP || res == TXRX_QUEUED) | 1854 | if (res == TXRX_DROP || res == TXRX_QUEUED) |
1858 | break; | 1855 | break; |
1859 | } | 1856 | } |
1860 | dev_put(tx.dev); | ||
1861 | skb = tx.skb; /* handlers are allowed to change skb */ | 1857 | skb = tx.skb; /* handlers are allowed to change skb */ |
1862 | 1858 | ||
1863 | if (res == TXRX_DROP) { | 1859 | if (res == TXRX_DROP) { |