Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 1 | /* |
Rui Paulo | 264d9b7 | 2009-11-09 23:46:58 +0000 | [diff] [blame] | 2 | * Copyright (c) 2008, 2009 open80211s Ltd. |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 3 | * Author: Luis Carlos Cobo <luisca@cozybit.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation. |
| 8 | */ |
| 9 | |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 10 | #include <linux/slab.h> |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 11 | #include "mesh.h" |
| 12 | |
Rui Paulo | 27db2e4 | 2009-11-09 23:46:45 +0000 | [diff] [blame] | 13 | #ifdef CONFIG_MAC80211_VERBOSE_MHWMP_DEBUG |
Javier Cardona | 7646887 | 2011-08-09 16:45:04 -0700 | [diff] [blame] | 14 | #define mhwmp_dbg(fmt, args...) \ |
| 15 | printk(KERN_DEBUG "Mesh HWMP (%s): " fmt "\n", sdata->name, ##args) |
Rui Paulo | 27db2e4 | 2009-11-09 23:46:45 +0000 | [diff] [blame] | 16 | #else |
| 17 | #define mhwmp_dbg(fmt, args...) do { (void)(0); } while (0) |
| 18 | #endif |
| 19 | |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 20 | #define TEST_FRAME_LEN 8192 |
| 21 | #define MAX_METRIC 0xffffffff |
| 22 | #define ARITH_SHIFT 8 |
| 23 | |
| 24 | /* Number of frames buffered per destination for unresolved destinations */ |
| 25 | #define MESH_FRAME_QUEUE_LEN 10 |
| 26 | #define MAX_PREQ_QUEUE_LEN 64 |
| 27 | |
| 28 | /* Destination only */ |
| 29 | #define MP_F_DO 0x1 |
| 30 | /* Reply and forward */ |
| 31 | #define MP_F_RF 0x2 |
Rui Paulo | d611f06 | 2009-11-09 23:46:50 +0000 | [diff] [blame] | 32 | /* Unknown Sequence Number */ |
| 33 | #define MP_F_USN 0x01 |
| 34 | /* Reason code Present */ |
| 35 | #define MP_F_RCODE 0x02 |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 36 | |
Rui Paulo | 90a5e16 | 2009-11-11 00:01:31 +0000 | [diff] [blame] | 37 | static void mesh_queue_preq(struct mesh_path *, u8); |
| 38 | |
Luis Carlos Cobo | a00de5d | 2008-02-29 17:07:54 -0800 | [diff] [blame] | 39 | static inline u32 u32_field_get(u8 *preq_elem, int offset, bool ae) |
| 40 | { |
| 41 | if (ae) |
| 42 | offset += 6; |
Harvey Harrison | ae7245c | 2008-05-01 22:19:33 -0700 | [diff] [blame] | 43 | return get_unaligned_le32(preq_elem + offset); |
Luis Carlos Cobo | a00de5d | 2008-02-29 17:07:54 -0800 | [diff] [blame] | 44 | } |
| 45 | |
Rui Paulo | d611f06 | 2009-11-09 23:46:50 +0000 | [diff] [blame] | 46 | static inline u32 u16_field_get(u8 *preq_elem, int offset, bool ae) |
| 47 | { |
| 48 | if (ae) |
| 49 | offset += 6; |
| 50 | return get_unaligned_le16(preq_elem + offset); |
| 51 | } |
| 52 | |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 53 | /* HWMP IE processing macros */ |
Luis Carlos Cobo | a00de5d | 2008-02-29 17:07:54 -0800 | [diff] [blame] | 54 | #define AE_F (1<<6) |
| 55 | #define AE_F_SET(x) (*x & AE_F) |
| 56 | #define PREQ_IE_FLAGS(x) (*(x)) |
| 57 | #define PREQ_IE_HOPCOUNT(x) (*(x + 1)) |
| 58 | #define PREQ_IE_TTL(x) (*(x + 2)) |
| 59 | #define PREQ_IE_PREQ_ID(x) u32_field_get(x, 3, 0) |
| 60 | #define PREQ_IE_ORIG_ADDR(x) (x + 7) |
Phil Carmody | 497888c | 2011-07-14 15:07:13 +0300 | [diff] [blame] | 61 | #define PREQ_IE_ORIG_SN(x) u32_field_get(x, 13, 0) |
| 62 | #define PREQ_IE_LIFETIME(x) u32_field_get(x, 17, AE_F_SET(x)) |
| 63 | #define PREQ_IE_METRIC(x) u32_field_get(x, 21, AE_F_SET(x)) |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 64 | #define PREQ_IE_TARGET_F(x) (*(AE_F_SET(x) ? x + 32 : x + 26)) |
| 65 | #define PREQ_IE_TARGET_ADDR(x) (AE_F_SET(x) ? x + 33 : x + 27) |
Phil Carmody | 497888c | 2011-07-14 15:07:13 +0300 | [diff] [blame] | 66 | #define PREQ_IE_TARGET_SN(x) u32_field_get(x, 33, AE_F_SET(x)) |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 67 | |
| 68 | |
Luis Carlos Cobo | a00de5d | 2008-02-29 17:07:54 -0800 | [diff] [blame] | 69 | #define PREP_IE_FLAGS(x) PREQ_IE_FLAGS(x) |
| 70 | #define PREP_IE_HOPCOUNT(x) PREQ_IE_HOPCOUNT(x) |
| 71 | #define PREP_IE_TTL(x) PREQ_IE_TTL(x) |
Thomas Pedersen | 25d49e4 | 2011-08-11 19:35:15 -0700 | [diff] [blame] | 72 | #define PREP_IE_ORIG_ADDR(x) (AE_F_SET(x) ? x + 27 : x + 21) |
| 73 | #define PREP_IE_ORIG_SN(x) u32_field_get(x, 27, AE_F_SET(x)) |
Phil Carmody | 497888c | 2011-07-14 15:07:13 +0300 | [diff] [blame] | 74 | #define PREP_IE_LIFETIME(x) u32_field_get(x, 13, AE_F_SET(x)) |
| 75 | #define PREP_IE_METRIC(x) u32_field_get(x, 17, AE_F_SET(x)) |
Thomas Pedersen | 25d49e4 | 2011-08-11 19:35:15 -0700 | [diff] [blame] | 76 | #define PREP_IE_TARGET_ADDR(x) (x + 3) |
| 77 | #define PREP_IE_TARGET_SN(x) u32_field_get(x, 9, 0) |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 78 | |
Rui Paulo | d611f06 | 2009-11-09 23:46:50 +0000 | [diff] [blame] | 79 | #define PERR_IE_TTL(x) (*(x)) |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 80 | #define PERR_IE_TARGET_FLAGS(x) (*(x + 2)) |
| 81 | #define PERR_IE_TARGET_ADDR(x) (x + 3) |
Phil Carmody | 497888c | 2011-07-14 15:07:13 +0300 | [diff] [blame] | 82 | #define PERR_IE_TARGET_SN(x) u32_field_get(x, 9, 0) |
| 83 | #define PERR_IE_TARGET_RCODE(x) u16_field_get(x, 13, 0) |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 84 | |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 85 | #define MSEC_TO_TU(x) (x*1000/1024) |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 86 | #define SN_GT(x, y) ((long) (y) - (long) (x) < 0) |
| 87 | #define SN_LT(x, y) ((long) (x) - (long) (y) < 0) |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 88 | |
| 89 | #define net_traversal_jiffies(s) \ |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 90 | msecs_to_jiffies(s->u.mesh.mshcfg.dot11MeshHWMPnetDiameterTraversalTime) |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 91 | #define default_lifetime(s) \ |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 92 | MSEC_TO_TU(s->u.mesh.mshcfg.dot11MeshHWMPactivePathTimeout) |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 93 | #define min_preq_int_jiff(s) \ |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 94 | (msecs_to_jiffies(s->u.mesh.mshcfg.dot11MeshHWMPpreqMinInterval)) |
| 95 | #define max_preq_retries(s) (s->u.mesh.mshcfg.dot11MeshHWMPmaxPREQretries) |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 96 | #define disc_timeout_jiff(s) \ |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 97 | msecs_to_jiffies(sdata->u.mesh.mshcfg.min_discovery_timeout) |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 98 | |
| 99 | enum mpath_frame_type { |
| 100 | MPATH_PREQ = 0, |
| 101 | MPATH_PREP, |
Rui Paulo | 90a5e16 | 2009-11-11 00:01:31 +0000 | [diff] [blame] | 102 | MPATH_PERR, |
| 103 | MPATH_RANN |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 104 | }; |
| 105 | |
Johannes Berg | 15ff636 | 2009-11-17 13:34:04 +0100 | [diff] [blame] | 106 | static const u8 broadcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 107 | |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 108 | static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags, |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 109 | u8 *orig_addr, __le32 orig_sn, u8 target_flags, u8 *target, |
Johannes Berg | 15ff636 | 2009-11-17 13:34:04 +0100 | [diff] [blame] | 110 | __le32 target_sn, const u8 *da, u8 hop_count, u8 ttl, |
| 111 | __le32 lifetime, __le32 metric, __le32 preq_id, |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 112 | struct ieee80211_sub_if_data *sdata) |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 113 | { |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 114 | struct ieee80211_local *local = sdata->local; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 115 | struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); |
| 116 | struct ieee80211_mgmt *mgmt; |
| 117 | u8 *pos; |
| 118 | int ie_len; |
| 119 | |
| 120 | if (!skb) |
| 121 | return -1; |
| 122 | skb_reserve(skb, local->hw.extra_tx_headroom); |
| 123 | /* 25 is the size of the common mgmt part (24) plus the size of the |
| 124 | * common action part (1) |
| 125 | */ |
| 126 | mgmt = (struct ieee80211_mgmt *) |
| 127 | skb_put(skb, 25 + sizeof(mgmt->u.action.u.mesh_action)); |
| 128 | memset(mgmt, 0, 25 + sizeof(mgmt->u.action.u.mesh_action)); |
Harvey Harrison | e7827a7 | 2008-07-15 18:44:13 -0700 | [diff] [blame] | 129 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
| 130 | IEEE80211_STYPE_ACTION); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 131 | |
| 132 | memcpy(mgmt->da, da, ETH_ALEN); |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 133 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); |
Rui Paulo | 90a5e16 | 2009-11-11 00:01:31 +0000 | [diff] [blame] | 134 | /* BSSID == SA */ |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 135 | memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN); |
Thomas Pedersen | 25d49e4 | 2011-08-11 19:35:15 -0700 | [diff] [blame] | 136 | mgmt->u.action.category = WLAN_CATEGORY_MESH_ACTION; |
| 137 | mgmt->u.action.u.mesh_action.action_code = |
| 138 | WLAN_MESH_ACTION_HWMP_PATH_SELECTION; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 139 | |
| 140 | switch (action) { |
| 141 | case MPATH_PREQ: |
Javier Cardona | 7646887 | 2011-08-09 16:45:04 -0700 | [diff] [blame] | 142 | mhwmp_dbg("sending PREQ to %pM", target); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 143 | ie_len = 37; |
| 144 | pos = skb_put(skb, 2 + ie_len); |
| 145 | *pos++ = WLAN_EID_PREQ; |
| 146 | break; |
| 147 | case MPATH_PREP: |
Javier Cardona | 7646887 | 2011-08-09 16:45:04 -0700 | [diff] [blame] | 148 | mhwmp_dbg("sending PREP to %pM", target); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 149 | ie_len = 31; |
| 150 | pos = skb_put(skb, 2 + ie_len); |
| 151 | *pos++ = WLAN_EID_PREP; |
| 152 | break; |
Rui Paulo | 90a5e16 | 2009-11-11 00:01:31 +0000 | [diff] [blame] | 153 | case MPATH_RANN: |
Javier Cardona | 7646887 | 2011-08-09 16:45:04 -0700 | [diff] [blame] | 154 | mhwmp_dbg("sending RANN from %pM", orig_addr); |
Rui Paulo | 90a5e16 | 2009-11-11 00:01:31 +0000 | [diff] [blame] | 155 | ie_len = sizeof(struct ieee80211_rann_ie); |
| 156 | pos = skb_put(skb, 2 + ie_len); |
| 157 | *pos++ = WLAN_EID_RANN; |
| 158 | break; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 159 | default: |
Patrick McHardy | 812714d | 2008-05-06 12:52:07 +0200 | [diff] [blame] | 160 | kfree_skb(skb); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 161 | return -ENOTSUPP; |
| 162 | break; |
| 163 | } |
| 164 | *pos++ = ie_len; |
| 165 | *pos++ = flags; |
| 166 | *pos++ = hop_count; |
| 167 | *pos++ = ttl; |
Thomas Pedersen | 25d49e4 | 2011-08-11 19:35:15 -0700 | [diff] [blame] | 168 | if (action == MPATH_PREP) { |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 169 | memcpy(pos, target, ETH_ALEN); |
Rui Paulo | 90a5e16 | 2009-11-11 00:01:31 +0000 | [diff] [blame] | 170 | pos += ETH_ALEN; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 171 | memcpy(pos, &target_sn, 4); |
Thomas Pedersen | 25d49e4 | 2011-08-11 19:35:15 -0700 | [diff] [blame] | 172 | pos += 4; |
| 173 | } else { |
| 174 | if (action == MPATH_PREQ) { |
| 175 | memcpy(pos, &preq_id, 4); |
| 176 | pos += 4; |
| 177 | } |
| 178 | memcpy(pos, orig_addr, ETH_ALEN); |
| 179 | pos += ETH_ALEN; |
| 180 | memcpy(pos, &orig_sn, 4); |
| 181 | pos += 4; |
| 182 | } |
| 183 | memcpy(pos, &lifetime, 4); /* interval for RANN */ |
| 184 | pos += 4; |
| 185 | memcpy(pos, &metric, 4); |
| 186 | pos += 4; |
| 187 | if (action == MPATH_PREQ) { |
| 188 | *pos++ = 1; /* destination count */ |
| 189 | *pos++ = target_flags; |
| 190 | memcpy(pos, target, ETH_ALEN); |
| 191 | pos += ETH_ALEN; |
| 192 | memcpy(pos, &target_sn, 4); |
| 193 | pos += 4; |
| 194 | } else if (action == MPATH_PREP) { |
| 195 | memcpy(pos, orig_addr, ETH_ALEN); |
| 196 | pos += ETH_ALEN; |
| 197 | memcpy(pos, &orig_sn, 4); |
| 198 | pos += 4; |
Rui Paulo | 90a5e16 | 2009-11-11 00:01:31 +0000 | [diff] [blame] | 199 | } |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 200 | |
Johannes Berg | 62ae67b | 2009-11-18 18:42:05 +0100 | [diff] [blame] | 201 | ieee80211_tx_skb(sdata, skb); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 202 | return 0; |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * mesh_send_path error - Sends a PERR mesh management frame |
| 207 | * |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 208 | * @target: broken destination |
| 209 | * @target_sn: SN of the broken destination |
| 210 | * @target_rcode: reason code for this PERR |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 211 | * @ra: node this frame is addressed to |
| 212 | */ |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 213 | int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn, |
Johannes Berg | 15ff636 | 2009-11-17 13:34:04 +0100 | [diff] [blame] | 214 | __le16 target_rcode, const u8 *ra, |
| 215 | struct ieee80211_sub_if_data *sdata) |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 216 | { |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 217 | struct ieee80211_local *local = sdata->local; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 218 | struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); |
| 219 | struct ieee80211_mgmt *mgmt; |
| 220 | u8 *pos; |
| 221 | int ie_len; |
| 222 | |
| 223 | if (!skb) |
| 224 | return -1; |
| 225 | skb_reserve(skb, local->hw.extra_tx_headroom); |
| 226 | /* 25 is the size of the common mgmt part (24) plus the size of the |
| 227 | * common action part (1) |
| 228 | */ |
| 229 | mgmt = (struct ieee80211_mgmt *) |
| 230 | skb_put(skb, 25 + sizeof(mgmt->u.action.u.mesh_action)); |
| 231 | memset(mgmt, 0, 25 + sizeof(mgmt->u.action.u.mesh_action)); |
Harvey Harrison | e7827a7 | 2008-07-15 18:44:13 -0700 | [diff] [blame] | 232 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
| 233 | IEEE80211_STYPE_ACTION); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 234 | |
| 235 | memcpy(mgmt->da, ra, ETH_ALEN); |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 236 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); |
Thomas Pedersen | 25d49e4 | 2011-08-11 19:35:15 -0700 | [diff] [blame] | 237 | /* BSSID == SA */ |
| 238 | memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN); |
| 239 | mgmt->u.action.category = WLAN_CATEGORY_MESH_ACTION; |
| 240 | mgmt->u.action.u.mesh_action.action_code = |
| 241 | WLAN_MESH_ACTION_HWMP_PATH_SELECTION; |
Rui Paulo | d611f06 | 2009-11-09 23:46:50 +0000 | [diff] [blame] | 242 | ie_len = 15; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 243 | pos = skb_put(skb, 2 + ie_len); |
| 244 | *pos++ = WLAN_EID_PERR; |
| 245 | *pos++ = ie_len; |
Rui Paulo | d611f06 | 2009-11-09 23:46:50 +0000 | [diff] [blame] | 246 | /* ttl */ |
Javier Cardona | 45904f2 | 2010-12-03 09:20:40 +0100 | [diff] [blame] | 247 | *pos++ = ttl; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 248 | /* number of destinations */ |
| 249 | *pos++ = 1; |
Rui Paulo | d611f06 | 2009-11-09 23:46:50 +0000 | [diff] [blame] | 250 | /* |
| 251 | * flags bit, bit 1 is unset if we know the sequence number and |
| 252 | * bit 2 is set if we have a reason code |
| 253 | */ |
| 254 | *pos = 0; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 255 | if (!target_sn) |
Rui Paulo | d611f06 | 2009-11-09 23:46:50 +0000 | [diff] [blame] | 256 | *pos |= MP_F_USN; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 257 | if (target_rcode) |
Rui Paulo | d611f06 | 2009-11-09 23:46:50 +0000 | [diff] [blame] | 258 | *pos |= MP_F_RCODE; |
| 259 | pos++; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 260 | memcpy(pos, target, ETH_ALEN); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 261 | pos += ETH_ALEN; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 262 | memcpy(pos, &target_sn, 4); |
Rui Paulo | d611f06 | 2009-11-09 23:46:50 +0000 | [diff] [blame] | 263 | pos += 4; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 264 | memcpy(pos, &target_rcode, 2); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 265 | |
Johannes Berg | 62ae67b | 2009-11-18 18:42:05 +0100 | [diff] [blame] | 266 | ieee80211_tx_skb(sdata, skb); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 267 | return 0; |
| 268 | } |
| 269 | |
Javier Cardona | bfc32e6 | 2009-08-17 17:15:55 -0700 | [diff] [blame] | 270 | void ieee80211s_update_metric(struct ieee80211_local *local, |
| 271 | struct sta_info *stainfo, struct sk_buff *skb) |
| 272 | { |
| 273 | struct ieee80211_tx_info *txinfo = IEEE80211_SKB_CB(skb); |
| 274 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
| 275 | int failed; |
| 276 | |
| 277 | if (!ieee80211_is_data(hdr->frame_control)) |
| 278 | return; |
| 279 | |
| 280 | failed = !(txinfo->flags & IEEE80211_TX_STAT_ACK); |
| 281 | |
| 282 | /* moving average, scaled to 100 */ |
| 283 | stainfo->fail_avg = ((80 * stainfo->fail_avg + 5) / 100 + 20 * failed); |
| 284 | if (stainfo->fail_avg > 95) |
| 285 | mesh_plink_broken(stainfo); |
| 286 | } |
| 287 | |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 288 | static u32 airtime_link_metric_get(struct ieee80211_local *local, |
| 289 | struct sta_info *sta) |
| 290 | { |
| 291 | struct ieee80211_supported_band *sband; |
| 292 | /* This should be adjusted for each device */ |
| 293 | int device_constant = 1 << ARITH_SHIFT; |
| 294 | int test_frame_len = TEST_FRAME_LEN << ARITH_SHIFT; |
| 295 | int s_unit = 1 << ARITH_SHIFT; |
| 296 | int rate, err; |
| 297 | u32 tx_time, estimated_retx; |
| 298 | u64 result; |
| 299 | |
| 300 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; |
| 301 | |
| 302 | if (sta->fail_avg >= 100) |
| 303 | return MAX_METRIC; |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 304 | |
| 305 | if (sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS) |
| 306 | return MAX_METRIC; |
| 307 | |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 308 | err = (sta->fail_avg << ARITH_SHIFT) / 100; |
| 309 | |
| 310 | /* bitrate is in units of 100 Kbps, while we need rate in units of |
| 311 | * 1Mbps. This will be corrected on tx_time computation. |
| 312 | */ |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 313 | rate = sband->bitrates[sta->last_tx_rate.idx].bitrate; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 314 | tx_time = (device_constant + 10 * test_frame_len / rate); |
| 315 | estimated_retx = ((1 << (2 * ARITH_SHIFT)) / (s_unit - err)); |
| 316 | result = (tx_time * estimated_retx) >> (2 * ARITH_SHIFT) ; |
| 317 | return (u32)result; |
| 318 | } |
| 319 | |
| 320 | /** |
| 321 | * hwmp_route_info_get - Update routing info to originator and transmitter |
| 322 | * |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 323 | * @sdata: local mesh subif |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 324 | * @mgmt: mesh management frame |
| 325 | * @hwmp_ie: hwmp information element (PREP or PREQ) |
| 326 | * |
| 327 | * This function updates the path routing information to the originator and the |
Andrey Yurovsky | f99288d | 2009-10-20 12:17:34 -0700 | [diff] [blame] | 328 | * transmitter of a HWMP PREQ or PREP frame. |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 329 | * |
| 330 | * Returns: metric to frame originator or 0 if the frame should not be further |
| 331 | * processed |
| 332 | * |
| 333 | * Notes: this function is the only place (besides user-provided info) where |
| 334 | * path routing information is updated. |
| 335 | */ |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 336 | static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 337 | struct ieee80211_mgmt *mgmt, |
Rui Paulo | dbb81c4 | 2009-11-09 23:46:46 +0000 | [diff] [blame] | 338 | u8 *hwmp_ie, enum mpath_frame_type action) |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 339 | { |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 340 | struct ieee80211_local *local = sdata->local; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 341 | struct mesh_path *mpath; |
| 342 | struct sta_info *sta; |
| 343 | bool fresh_info; |
| 344 | u8 *orig_addr, *ta; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 345 | u32 orig_sn, orig_metric; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 346 | unsigned long orig_lifetime, exp_time; |
| 347 | u32 last_hop_metric, new_metric; |
| 348 | bool process = true; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 349 | |
| 350 | rcu_read_lock(); |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 351 | sta = sta_info_get(sdata, mgmt->sa); |
Johannes Berg | dc0b0f7 | 2008-02-23 15:17:20 +0100 | [diff] [blame] | 352 | if (!sta) { |
| 353 | rcu_read_unlock(); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 354 | return 0; |
Johannes Berg | dc0b0f7 | 2008-02-23 15:17:20 +0100 | [diff] [blame] | 355 | } |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 356 | |
| 357 | last_hop_metric = airtime_link_metric_get(local, sta); |
| 358 | /* Update and check originator routing info */ |
| 359 | fresh_info = true; |
| 360 | |
| 361 | switch (action) { |
| 362 | case MPATH_PREQ: |
| 363 | orig_addr = PREQ_IE_ORIG_ADDR(hwmp_ie); |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 364 | orig_sn = PREQ_IE_ORIG_SN(hwmp_ie); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 365 | orig_lifetime = PREQ_IE_LIFETIME(hwmp_ie); |
| 366 | orig_metric = PREQ_IE_METRIC(hwmp_ie); |
| 367 | break; |
| 368 | case MPATH_PREP: |
| 369 | /* Originator here refers to the MP that was the destination in |
| 370 | * the Path Request. The draft refers to that MP as the |
| 371 | * destination address, even though usually it is the origin of |
| 372 | * the PREP frame. We divert from the nomenclature in the draft |
| 373 | * so that we can easily use a single function to gather path |
| 374 | * information from both PREQ and PREP frames. |
| 375 | */ |
| 376 | orig_addr = PREP_IE_ORIG_ADDR(hwmp_ie); |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 377 | orig_sn = PREP_IE_ORIG_SN(hwmp_ie); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 378 | orig_lifetime = PREP_IE_LIFETIME(hwmp_ie); |
| 379 | orig_metric = PREP_IE_METRIC(hwmp_ie); |
| 380 | break; |
| 381 | default: |
Johannes Berg | dc0b0f7 | 2008-02-23 15:17:20 +0100 | [diff] [blame] | 382 | rcu_read_unlock(); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 383 | return 0; |
| 384 | } |
| 385 | new_metric = orig_metric + last_hop_metric; |
| 386 | if (new_metric < orig_metric) |
| 387 | new_metric = MAX_METRIC; |
| 388 | exp_time = TU_TO_EXP_TIME(orig_lifetime); |
| 389 | |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 390 | if (memcmp(orig_addr, sdata->vif.addr, ETH_ALEN) == 0) { |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 391 | /* This MP is the originator, we are not interested in this |
| 392 | * frame, except for updating transmitter's path info. |
| 393 | */ |
| 394 | process = false; |
| 395 | fresh_info = false; |
| 396 | } else { |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 397 | mpath = mesh_path_lookup(orig_addr, sdata); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 398 | if (mpath) { |
| 399 | spin_lock_bh(&mpath->state_lock); |
| 400 | if (mpath->flags & MESH_PATH_FIXED) |
| 401 | fresh_info = false; |
| 402 | else if ((mpath->flags & MESH_PATH_ACTIVE) && |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 403 | (mpath->flags & MESH_PATH_SN_VALID)) { |
| 404 | if (SN_GT(mpath->sn, orig_sn) || |
| 405 | (mpath->sn == orig_sn && |
Porsch, Marco | 533866b | 2010-02-24 09:53:13 +0100 | [diff] [blame] | 406 | new_metric >= mpath->metric)) { |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 407 | process = false; |
| 408 | fresh_info = false; |
| 409 | } |
| 410 | } |
| 411 | } else { |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 412 | mesh_path_add(orig_addr, sdata); |
| 413 | mpath = mesh_path_lookup(orig_addr, sdata); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 414 | if (!mpath) { |
| 415 | rcu_read_unlock(); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 416 | return 0; |
| 417 | } |
| 418 | spin_lock_bh(&mpath->state_lock); |
| 419 | } |
| 420 | |
| 421 | if (fresh_info) { |
| 422 | mesh_path_assign_nexthop(mpath, sta); |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 423 | mpath->flags |= MESH_PATH_SN_VALID; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 424 | mpath->metric = new_metric; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 425 | mpath->sn = orig_sn; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 426 | mpath->exp_time = time_after(mpath->exp_time, exp_time) |
| 427 | ? mpath->exp_time : exp_time; |
| 428 | mesh_path_activate(mpath); |
| 429 | spin_unlock_bh(&mpath->state_lock); |
| 430 | mesh_path_tx_pending(mpath); |
| 431 | /* draft says preq_id should be saved to, but there does |
| 432 | * not seem to be any use for it, skipping by now |
| 433 | */ |
| 434 | } else |
| 435 | spin_unlock_bh(&mpath->state_lock); |
| 436 | } |
| 437 | |
| 438 | /* Update and check transmitter routing info */ |
| 439 | ta = mgmt->sa; |
| 440 | if (memcmp(orig_addr, ta, ETH_ALEN) == 0) |
| 441 | fresh_info = false; |
| 442 | else { |
| 443 | fresh_info = true; |
| 444 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 445 | mpath = mesh_path_lookup(ta, sdata); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 446 | if (mpath) { |
| 447 | spin_lock_bh(&mpath->state_lock); |
| 448 | if ((mpath->flags & MESH_PATH_FIXED) || |
| 449 | ((mpath->flags & MESH_PATH_ACTIVE) && |
| 450 | (last_hop_metric > mpath->metric))) |
| 451 | fresh_info = false; |
| 452 | } else { |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 453 | mesh_path_add(ta, sdata); |
| 454 | mpath = mesh_path_lookup(ta, sdata); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 455 | if (!mpath) { |
| 456 | rcu_read_unlock(); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 457 | return 0; |
| 458 | } |
| 459 | spin_lock_bh(&mpath->state_lock); |
| 460 | } |
| 461 | |
| 462 | if (fresh_info) { |
| 463 | mesh_path_assign_nexthop(mpath, sta); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 464 | mpath->metric = last_hop_metric; |
| 465 | mpath->exp_time = time_after(mpath->exp_time, exp_time) |
| 466 | ? mpath->exp_time : exp_time; |
| 467 | mesh_path_activate(mpath); |
| 468 | spin_unlock_bh(&mpath->state_lock); |
| 469 | mesh_path_tx_pending(mpath); |
| 470 | } else |
| 471 | spin_unlock_bh(&mpath->state_lock); |
| 472 | } |
| 473 | |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 474 | rcu_read_unlock(); |
| 475 | |
| 476 | return process ? new_metric : 0; |
| 477 | } |
| 478 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 479 | static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 480 | struct ieee80211_mgmt *mgmt, |
David Woo | 57ef5dd | 2009-08-12 11:03:43 -0700 | [diff] [blame] | 481 | u8 *preq_elem, u32 metric) |
| 482 | { |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 483 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 484 | struct mesh_path *mpath; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 485 | u8 *target_addr, *orig_addr; |
| 486 | u8 target_flags, ttl; |
| 487 | u32 orig_sn, target_sn, lifetime; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 488 | bool reply = false; |
| 489 | bool forward = true; |
| 490 | |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 491 | /* Update target SN, if present */ |
| 492 | target_addr = PREQ_IE_TARGET_ADDR(preq_elem); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 493 | orig_addr = PREQ_IE_ORIG_ADDR(preq_elem); |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 494 | target_sn = PREQ_IE_TARGET_SN(preq_elem); |
| 495 | orig_sn = PREQ_IE_ORIG_SN(preq_elem); |
| 496 | target_flags = PREQ_IE_TARGET_F(preq_elem); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 497 | |
Javier Cardona | 7646887 | 2011-08-09 16:45:04 -0700 | [diff] [blame] | 498 | mhwmp_dbg("received PREQ from %pM", orig_addr); |
Rui Paulo | 27db2e4 | 2009-11-09 23:46:45 +0000 | [diff] [blame] | 499 | |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 500 | if (memcmp(target_addr, sdata->vif.addr, ETH_ALEN) == 0) { |
Javier Cardona | 7646887 | 2011-08-09 16:45:04 -0700 | [diff] [blame] | 501 | mhwmp_dbg("PREQ is for us"); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 502 | forward = false; |
| 503 | reply = true; |
| 504 | metric = 0; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 505 | if (time_after(jiffies, ifmsh->last_sn_update + |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 506 | net_traversal_jiffies(sdata)) || |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 507 | time_before(jiffies, ifmsh->last_sn_update)) { |
| 508 | target_sn = ++ifmsh->sn; |
| 509 | ifmsh->last_sn_update = jiffies; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 510 | } |
| 511 | } else { |
| 512 | rcu_read_lock(); |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 513 | mpath = mesh_path_lookup(target_addr, sdata); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 514 | if (mpath) { |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 515 | if ((!(mpath->flags & MESH_PATH_SN_VALID)) || |
| 516 | SN_LT(mpath->sn, target_sn)) { |
| 517 | mpath->sn = target_sn; |
| 518 | mpath->flags |= MESH_PATH_SN_VALID; |
| 519 | } else if ((!(target_flags & MP_F_DO)) && |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 520 | (mpath->flags & MESH_PATH_ACTIVE)) { |
| 521 | reply = true; |
| 522 | metric = mpath->metric; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 523 | target_sn = mpath->sn; |
| 524 | if (target_flags & MP_F_RF) |
| 525 | target_flags |= MP_F_DO; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 526 | else |
| 527 | forward = false; |
| 528 | } |
| 529 | } |
| 530 | rcu_read_unlock(); |
| 531 | } |
| 532 | |
| 533 | if (reply) { |
| 534 | lifetime = PREQ_IE_LIFETIME(preq_elem); |
Javier Cardona | 45904f2 | 2010-12-03 09:20:40 +0100 | [diff] [blame] | 535 | ttl = ifmsh->mshcfg.element_ttl; |
Rui Paulo | 27db2e4 | 2009-11-09 23:46:45 +0000 | [diff] [blame] | 536 | if (ttl != 0) { |
Javier Cardona | 7646887 | 2011-08-09 16:45:04 -0700 | [diff] [blame] | 537 | mhwmp_dbg("replying to the PREQ"); |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 538 | mesh_path_sel_frame_tx(MPATH_PREP, 0, target_addr, |
| 539 | cpu_to_le32(target_sn), 0, orig_addr, |
| 540 | cpu_to_le32(orig_sn), mgmt->sa, 0, ttl, |
Luis Carlos Cobo | aa2b592 | 2008-02-29 14:30:32 -0800 | [diff] [blame] | 541 | cpu_to_le32(lifetime), cpu_to_le32(metric), |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 542 | 0, sdata); |
Rui Paulo | 27db2e4 | 2009-11-09 23:46:45 +0000 | [diff] [blame] | 543 | } else |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 544 | ifmsh->mshstats.dropped_frames_ttl++; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 545 | } |
| 546 | |
| 547 | if (forward) { |
| 548 | u32 preq_id; |
| 549 | u8 hopcount, flags; |
| 550 | |
| 551 | ttl = PREQ_IE_TTL(preq_elem); |
| 552 | lifetime = PREQ_IE_LIFETIME(preq_elem); |
| 553 | if (ttl <= 1) { |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 554 | ifmsh->mshstats.dropped_frames_ttl++; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 555 | return; |
| 556 | } |
Javier Cardona | 7646887 | 2011-08-09 16:45:04 -0700 | [diff] [blame] | 557 | mhwmp_dbg("forwarding the PREQ from %pM", orig_addr); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 558 | --ttl; |
| 559 | flags = PREQ_IE_FLAGS(preq_elem); |
| 560 | preq_id = PREQ_IE_PREQ_ID(preq_elem); |
| 561 | hopcount = PREQ_IE_HOPCOUNT(preq_elem) + 1; |
| 562 | mesh_path_sel_frame_tx(MPATH_PREQ, flags, orig_addr, |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 563 | cpu_to_le32(orig_sn), target_flags, target_addr, |
Johannes Berg | 15ff636 | 2009-11-17 13:34:04 +0100 | [diff] [blame] | 564 | cpu_to_le32(target_sn), broadcast_addr, |
Luis Carlos Cobo | aa2b592 | 2008-02-29 14:30:32 -0800 | [diff] [blame] | 565 | hopcount, ttl, cpu_to_le32(lifetime), |
| 566 | cpu_to_le32(metric), cpu_to_le32(preq_id), |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 567 | sdata); |
Daniel Walker | c8a61a7 | 2009-08-18 10:59:00 -0700 | [diff] [blame] | 568 | ifmsh->mshstats.fwded_mcast++; |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 569 | ifmsh->mshstats.fwded_frames++; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 570 | } |
| 571 | } |
| 572 | |
| 573 | |
Johannes Berg | 40b275b | 2011-05-13 14:15:49 +0200 | [diff] [blame] | 574 | static inline struct sta_info * |
| 575 | next_hop_deref_protected(struct mesh_path *mpath) |
| 576 | { |
| 577 | return rcu_dereference_protected(mpath->next_hop, |
| 578 | lockdep_is_held(&mpath->state_lock)); |
| 579 | } |
| 580 | |
| 581 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 582 | static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata, |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 583 | struct ieee80211_mgmt *mgmt, |
| 584 | u8 *prep_elem, u32 metric) |
| 585 | { |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 586 | struct mesh_path *mpath; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 587 | u8 *target_addr, *orig_addr; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 588 | u8 ttl, hopcount, flags; |
| 589 | u8 next_hop[ETH_ALEN]; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 590 | u32 target_sn, orig_sn, lifetime; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 591 | |
Javier Cardona | 7646887 | 2011-08-09 16:45:04 -0700 | [diff] [blame] | 592 | mhwmp_dbg("received PREP from %pM", PREP_IE_ORIG_ADDR(prep_elem)); |
Rui Paulo | dbb81c4 | 2009-11-09 23:46:46 +0000 | [diff] [blame] | 593 | |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 594 | /* Note that we divert from the draft nomenclature and denominate |
| 595 | * destination to what the draft refers to as origininator. So in this |
| 596 | * function destnation refers to the final destination of the PREP, |
| 597 | * which corresponds with the originator of the PREQ which this PREP |
| 598 | * replies |
| 599 | */ |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 600 | target_addr = PREP_IE_TARGET_ADDR(prep_elem); |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 601 | if (memcmp(target_addr, sdata->vif.addr, ETH_ALEN) == 0) |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 602 | /* destination, no forwarding required */ |
| 603 | return; |
| 604 | |
| 605 | ttl = PREP_IE_TTL(prep_elem); |
| 606 | if (ttl <= 1) { |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 607 | sdata->u.mesh.mshstats.dropped_frames_ttl++; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 608 | return; |
| 609 | } |
| 610 | |
| 611 | rcu_read_lock(); |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 612 | mpath = mesh_path_lookup(target_addr, sdata); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 613 | if (mpath) |
| 614 | spin_lock_bh(&mpath->state_lock); |
| 615 | else |
| 616 | goto fail; |
| 617 | if (!(mpath->flags & MESH_PATH_ACTIVE)) { |
| 618 | spin_unlock_bh(&mpath->state_lock); |
| 619 | goto fail; |
| 620 | } |
Johannes Berg | 40b275b | 2011-05-13 14:15:49 +0200 | [diff] [blame] | 621 | memcpy(next_hop, next_hop_deref_protected(mpath)->sta.addr, ETH_ALEN); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 622 | spin_unlock_bh(&mpath->state_lock); |
| 623 | --ttl; |
| 624 | flags = PREP_IE_FLAGS(prep_elem); |
| 625 | lifetime = PREP_IE_LIFETIME(prep_elem); |
| 626 | hopcount = PREP_IE_HOPCOUNT(prep_elem) + 1; |
| 627 | orig_addr = PREP_IE_ORIG_ADDR(prep_elem); |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 628 | target_sn = PREP_IE_TARGET_SN(prep_elem); |
| 629 | orig_sn = PREP_IE_ORIG_SN(prep_elem); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 630 | |
| 631 | mesh_path_sel_frame_tx(MPATH_PREP, flags, orig_addr, |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 632 | cpu_to_le32(orig_sn), 0, target_addr, |
Porsch, Marco | 533866b | 2010-02-24 09:53:13 +0100 | [diff] [blame] | 633 | cpu_to_le32(target_sn), next_hop, hopcount, |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 634 | ttl, cpu_to_le32(lifetime), cpu_to_le32(metric), |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 635 | 0, sdata); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 636 | rcu_read_unlock(); |
Daniel Walker | c8a61a7 | 2009-08-18 10:59:00 -0700 | [diff] [blame] | 637 | |
| 638 | sdata->u.mesh.mshstats.fwded_unicast++; |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 639 | sdata->u.mesh.mshstats.fwded_frames++; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 640 | return; |
| 641 | |
| 642 | fail: |
| 643 | rcu_read_unlock(); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 644 | sdata->u.mesh.mshstats.dropped_frames_no_route++; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 645 | } |
| 646 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 647 | static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata, |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 648 | struct ieee80211_mgmt *mgmt, u8 *perr_elem) |
| 649 | { |
Rui Paulo | d611f06 | 2009-11-09 23:46:50 +0000 | [diff] [blame] | 650 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 651 | struct mesh_path *mpath; |
Rui Paulo | d611f06 | 2009-11-09 23:46:50 +0000 | [diff] [blame] | 652 | u8 ttl; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 653 | u8 *ta, *target_addr; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 654 | u32 target_sn; |
| 655 | u16 target_rcode; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 656 | |
| 657 | ta = mgmt->sa; |
Rui Paulo | d611f06 | 2009-11-09 23:46:50 +0000 | [diff] [blame] | 658 | ttl = PERR_IE_TTL(perr_elem); |
| 659 | if (ttl <= 1) { |
| 660 | ifmsh->mshstats.dropped_frames_ttl++; |
| 661 | return; |
| 662 | } |
| 663 | ttl--; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 664 | target_addr = PERR_IE_TARGET_ADDR(perr_elem); |
| 665 | target_sn = PERR_IE_TARGET_SN(perr_elem); |
| 666 | target_rcode = PERR_IE_TARGET_RCODE(perr_elem); |
Rui Paulo | d611f06 | 2009-11-09 23:46:50 +0000 | [diff] [blame] | 667 | |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 668 | rcu_read_lock(); |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 669 | mpath = mesh_path_lookup(target_addr, sdata); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 670 | if (mpath) { |
| 671 | spin_lock_bh(&mpath->state_lock); |
| 672 | if (mpath->flags & MESH_PATH_ACTIVE && |
Johannes Berg | 40b275b | 2011-05-13 14:15:49 +0200 | [diff] [blame] | 673 | memcmp(ta, next_hop_deref_protected(mpath)->sta.addr, |
| 674 | ETH_ALEN) == 0 && |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 675 | (!(mpath->flags & MESH_PATH_SN_VALID) || |
| 676 | SN_GT(target_sn, mpath->sn))) { |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 677 | mpath->flags &= ~MESH_PATH_ACTIVE; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 678 | mpath->sn = target_sn; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 679 | spin_unlock_bh(&mpath->state_lock); |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 680 | mesh_path_error_tx(ttl, target_addr, cpu_to_le32(target_sn), |
| 681 | cpu_to_le16(target_rcode), |
Johannes Berg | 15ff636 | 2009-11-17 13:34:04 +0100 | [diff] [blame] | 682 | broadcast_addr, sdata); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 683 | } else |
| 684 | spin_unlock_bh(&mpath->state_lock); |
| 685 | } |
| 686 | rcu_read_unlock(); |
| 687 | } |
| 688 | |
Rui Paulo | 90a5e16 | 2009-11-11 00:01:31 +0000 | [diff] [blame] | 689 | static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata, |
| 690 | struct ieee80211_mgmt *mgmt, |
| 691 | struct ieee80211_rann_ie *rann) |
| 692 | { |
| 693 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
| 694 | struct mesh_path *mpath; |
Rui Paulo | 90a5e16 | 2009-11-11 00:01:31 +0000 | [diff] [blame] | 695 | u8 ttl, flags, hopcount; |
| 696 | u8 *orig_addr; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 697 | u32 orig_sn, metric; |
Javier Cardona | 0507e15 | 2011-08-09 16:45:10 -0700 | [diff] [blame^] | 698 | u32 interval = ifmsh->mshcfg.dot11MeshHWMPRannInterval; |
Javier Cardona | 5ee68e5 | 2011-08-09 16:45:08 -0700 | [diff] [blame] | 699 | bool root_is_gate; |
Rui Paulo | 90a5e16 | 2009-11-11 00:01:31 +0000 | [diff] [blame] | 700 | |
Rui Paulo | 90a5e16 | 2009-11-11 00:01:31 +0000 | [diff] [blame] | 701 | ttl = rann->rann_ttl; |
| 702 | if (ttl <= 1) { |
| 703 | ifmsh->mshstats.dropped_frames_ttl++; |
| 704 | return; |
| 705 | } |
| 706 | ttl--; |
| 707 | flags = rann->rann_flags; |
Javier Cardona | 5ee68e5 | 2011-08-09 16:45:08 -0700 | [diff] [blame] | 708 | root_is_gate = !!(flags & RANN_FLAG_IS_GATE); |
Rui Paulo | 90a5e16 | 2009-11-11 00:01:31 +0000 | [diff] [blame] | 709 | orig_addr = rann->rann_addr; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 710 | orig_sn = rann->rann_seq; |
Rui Paulo | 90a5e16 | 2009-11-11 00:01:31 +0000 | [diff] [blame] | 711 | hopcount = rann->rann_hopcount; |
Rui Paulo | a6a58b4 | 2009-11-09 23:46:51 +0000 | [diff] [blame] | 712 | hopcount++; |
Rui Paulo | 90a5e16 | 2009-11-11 00:01:31 +0000 | [diff] [blame] | 713 | metric = rann->rann_metric; |
Javier Cardona | 5ee68e5 | 2011-08-09 16:45:08 -0700 | [diff] [blame] | 714 | |
| 715 | /* Ignore our own RANNs */ |
| 716 | if (memcmp(orig_addr, sdata->vif.addr, ETH_ALEN) == 0) |
| 717 | return; |
| 718 | |
| 719 | mhwmp_dbg("received RANN from %pM (is_gate=%d)", orig_addr, |
| 720 | root_is_gate); |
Rui Paulo | 90a5e16 | 2009-11-11 00:01:31 +0000 | [diff] [blame] | 721 | |
| 722 | rcu_read_lock(); |
| 723 | mpath = mesh_path_lookup(orig_addr, sdata); |
| 724 | if (!mpath) { |
| 725 | mesh_path_add(orig_addr, sdata); |
| 726 | mpath = mesh_path_lookup(orig_addr, sdata); |
| 727 | if (!mpath) { |
| 728 | rcu_read_unlock(); |
| 729 | sdata->u.mesh.mshstats.dropped_frames_no_route++; |
| 730 | return; |
| 731 | } |
Rui Paulo | 90a5e16 | 2009-11-11 00:01:31 +0000 | [diff] [blame] | 732 | } |
Javier Cardona | 5ee68e5 | 2011-08-09 16:45:08 -0700 | [diff] [blame] | 733 | |
| 734 | if ((!(mpath->flags & (MESH_PATH_ACTIVE | MESH_PATH_RESOLVING)) || |
| 735 | time_after(jiffies, mpath->exp_time - 1*HZ)) && |
| 736 | !(mpath->flags & MESH_PATH_FIXED)) { |
| 737 | mhwmp_dbg("%s time to refresh root mpath %pM", sdata->name, |
| 738 | orig_addr); |
| 739 | mesh_queue_preq(mpath, PREQ_Q_F_START | PREQ_Q_F_REFRESH); |
| 740 | } |
| 741 | |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 742 | if (mpath->sn < orig_sn) { |
Rui Paulo | 90a5e16 | 2009-11-11 00:01:31 +0000 | [diff] [blame] | 743 | mesh_path_sel_frame_tx(MPATH_RANN, flags, orig_addr, |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 744 | cpu_to_le32(orig_sn), |
Johannes Berg | 15ff636 | 2009-11-17 13:34:04 +0100 | [diff] [blame] | 745 | 0, NULL, 0, broadcast_addr, |
Javier Cardona | 0507e15 | 2011-08-09 16:45:10 -0700 | [diff] [blame^] | 746 | hopcount, ttl, cpu_to_le32(interval), |
Rui Paulo | a6a58b4 | 2009-11-09 23:46:51 +0000 | [diff] [blame] | 747 | cpu_to_le32(metric + mpath->metric), |
Rui Paulo | 90a5e16 | 2009-11-11 00:01:31 +0000 | [diff] [blame] | 748 | 0, sdata); |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 749 | mpath->sn = orig_sn; |
Rui Paulo | 90a5e16 | 2009-11-11 00:01:31 +0000 | [diff] [blame] | 750 | } |
Javier Cardona | 5ee68e5 | 2011-08-09 16:45:08 -0700 | [diff] [blame] | 751 | if (root_is_gate) |
| 752 | mesh_path_add_gate(mpath); |
| 753 | |
Rui Paulo | 90a5e16 | 2009-11-11 00:01:31 +0000 | [diff] [blame] | 754 | rcu_read_unlock(); |
| 755 | } |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 756 | |
| 757 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 758 | void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata, |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 759 | struct ieee80211_mgmt *mgmt, |
| 760 | size_t len) |
| 761 | { |
| 762 | struct ieee802_11_elems elems; |
| 763 | size_t baselen; |
| 764 | u32 last_hop_metric; |
| 765 | |
Johannes Berg | 9c80d3d | 2008-09-08 15:41:59 +0200 | [diff] [blame] | 766 | /* need action_code */ |
| 767 | if (len < IEEE80211_MIN_ACTION_SIZE + 1) |
| 768 | return; |
| 769 | |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 770 | baselen = (u8 *) mgmt->u.action.u.mesh_action.variable - (u8 *) mgmt; |
| 771 | ieee802_11_parse_elems(mgmt->u.action.u.mesh_action.variable, |
| 772 | len - baselen, &elems); |
| 773 | |
Rui Paulo | dbb81c4 | 2009-11-09 23:46:46 +0000 | [diff] [blame] | 774 | if (elems.preq) { |
| 775 | if (elems.preq_len != 37) |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 776 | /* Right now we support just 1 destination and no AE */ |
| 777 | return; |
Rui Paulo | dbb81c4 | 2009-11-09 23:46:46 +0000 | [diff] [blame] | 778 | last_hop_metric = hwmp_route_info_get(sdata, mgmt, elems.preq, |
| 779 | MPATH_PREQ); |
| 780 | if (last_hop_metric) |
| 781 | hwmp_preq_frame_process(sdata, mgmt, elems.preq, |
| 782 | last_hop_metric); |
| 783 | } |
| 784 | if (elems.prep) { |
| 785 | if (elems.prep_len != 31) |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 786 | /* Right now we support no AE */ |
| 787 | return; |
Rui Paulo | dbb81c4 | 2009-11-09 23:46:46 +0000 | [diff] [blame] | 788 | last_hop_metric = hwmp_route_info_get(sdata, mgmt, elems.prep, |
| 789 | MPATH_PREP); |
| 790 | if (last_hop_metric) |
| 791 | hwmp_prep_frame_process(sdata, mgmt, elems.prep, |
| 792 | last_hop_metric); |
| 793 | } |
| 794 | if (elems.perr) { |
Rui Paulo | d611f06 | 2009-11-09 23:46:50 +0000 | [diff] [blame] | 795 | if (elems.perr_len != 15) |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 796 | /* Right now we support only one destination per PERR */ |
| 797 | return; |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 798 | hwmp_perr_frame_process(sdata, mgmt, elems.perr); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 799 | } |
Rui Paulo | 90a5e16 | 2009-11-11 00:01:31 +0000 | [diff] [blame] | 800 | if (elems.rann) |
| 801 | hwmp_rann_frame_process(sdata, mgmt, elems.rann); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 802 | } |
| 803 | |
| 804 | /** |
| 805 | * mesh_queue_preq - queue a PREQ to a given destination |
| 806 | * |
| 807 | * @mpath: mesh path to discover |
| 808 | * @flags: special attributes of the PREQ to be sent |
| 809 | * |
| 810 | * Locking: the function must be called from within a rcu read lock block. |
| 811 | * |
| 812 | */ |
| 813 | static void mesh_queue_preq(struct mesh_path *mpath, u8 flags) |
| 814 | { |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 815 | struct ieee80211_sub_if_data *sdata = mpath->sdata; |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 816 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 817 | struct mesh_preq_queue *preq_node; |
| 818 | |
Andrey Yurovsky | 59615b5 | 2009-06-25 16:07:42 -0700 | [diff] [blame] | 819 | preq_node = kmalloc(sizeof(struct mesh_preq_queue), GFP_ATOMIC); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 820 | if (!preq_node) { |
Javier Cardona | 7646887 | 2011-08-09 16:45:04 -0700 | [diff] [blame] | 821 | mhwmp_dbg("could not allocate PREQ node"); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 822 | return; |
| 823 | } |
| 824 | |
Baruch Siach | 987dafa | 2011-07-28 08:51:05 +0300 | [diff] [blame] | 825 | spin_lock_bh(&ifmsh->mesh_preq_queue_lock); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 826 | if (ifmsh->preq_queue_len == MAX_PREQ_QUEUE_LEN) { |
Baruch Siach | 987dafa | 2011-07-28 08:51:05 +0300 | [diff] [blame] | 827 | spin_unlock_bh(&ifmsh->mesh_preq_queue_lock); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 828 | kfree(preq_node); |
| 829 | if (printk_ratelimit()) |
Javier Cardona | 7646887 | 2011-08-09 16:45:04 -0700 | [diff] [blame] | 830 | mhwmp_dbg("PREQ node queue full"); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 831 | return; |
| 832 | } |
| 833 | |
| 834 | memcpy(preq_node->dst, mpath->dst, ETH_ALEN); |
| 835 | preq_node->flags = flags; |
| 836 | |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 837 | list_add_tail(&preq_node->list, &ifmsh->preq_queue.list); |
| 838 | ++ifmsh->preq_queue_len; |
Baruch Siach | 987dafa | 2011-07-28 08:51:05 +0300 | [diff] [blame] | 839 | spin_unlock_bh(&ifmsh->mesh_preq_queue_lock); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 840 | |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 841 | if (time_after(jiffies, ifmsh->last_preq + min_preq_int_jiff(sdata))) |
Johannes Berg | 64592c8 | 2010-06-10 10:21:31 +0200 | [diff] [blame] | 842 | ieee80211_queue_work(&sdata->local->hw, &sdata->work); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 843 | |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 844 | else if (time_before(jiffies, ifmsh->last_preq)) { |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 845 | /* avoid long wait if did not send preqs for a long time |
| 846 | * and jiffies wrapped around |
| 847 | */ |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 848 | ifmsh->last_preq = jiffies - min_preq_int_jiff(sdata) - 1; |
Johannes Berg | 64592c8 | 2010-06-10 10:21:31 +0200 | [diff] [blame] | 849 | ieee80211_queue_work(&sdata->local->hw, &sdata->work); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 850 | } else |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 851 | mod_timer(&ifmsh->mesh_path_timer, ifmsh->last_preq + |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 852 | min_preq_int_jiff(sdata)); |
| 853 | } |
| 854 | |
| 855 | /** |
| 856 | * mesh_path_start_discovery - launch a path discovery from the PREQ queue |
| 857 | * |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 858 | * @sdata: local mesh subif |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 859 | */ |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 860 | void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata) |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 861 | { |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 862 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 863 | struct mesh_preq_queue *preq_node; |
| 864 | struct mesh_path *mpath; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 865 | u8 ttl, target_flags; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 866 | u32 lifetime; |
| 867 | |
Johannes Berg | a43816d | 2009-07-10 11:39:26 +0200 | [diff] [blame] | 868 | spin_lock_bh(&ifmsh->mesh_preq_queue_lock); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 869 | if (!ifmsh->preq_queue_len || |
| 870 | time_before(jiffies, ifmsh->last_preq + |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 871 | min_preq_int_jiff(sdata))) { |
Johannes Berg | a43816d | 2009-07-10 11:39:26 +0200 | [diff] [blame] | 872 | spin_unlock_bh(&ifmsh->mesh_preq_queue_lock); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 873 | return; |
| 874 | } |
| 875 | |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 876 | preq_node = list_first_entry(&ifmsh->preq_queue.list, |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 877 | struct mesh_preq_queue, list); |
| 878 | list_del(&preq_node->list); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 879 | --ifmsh->preq_queue_len; |
Johannes Berg | a43816d | 2009-07-10 11:39:26 +0200 | [diff] [blame] | 880 | spin_unlock_bh(&ifmsh->mesh_preq_queue_lock); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 881 | |
| 882 | rcu_read_lock(); |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 883 | mpath = mesh_path_lookup(preq_node->dst, sdata); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 884 | if (!mpath) |
| 885 | goto enddiscovery; |
| 886 | |
| 887 | spin_lock_bh(&mpath->state_lock); |
| 888 | if (preq_node->flags & PREQ_Q_F_START) { |
| 889 | if (mpath->flags & MESH_PATH_RESOLVING) { |
| 890 | spin_unlock_bh(&mpath->state_lock); |
| 891 | goto enddiscovery; |
| 892 | } else { |
| 893 | mpath->flags &= ~MESH_PATH_RESOLVED; |
| 894 | mpath->flags |= MESH_PATH_RESOLVING; |
| 895 | mpath->discovery_retries = 0; |
| 896 | mpath->discovery_timeout = disc_timeout_jiff(sdata); |
| 897 | } |
| 898 | } else if (!(mpath->flags & MESH_PATH_RESOLVING) || |
| 899 | mpath->flags & MESH_PATH_RESOLVED) { |
| 900 | mpath->flags &= ~MESH_PATH_RESOLVING; |
| 901 | spin_unlock_bh(&mpath->state_lock); |
| 902 | goto enddiscovery; |
| 903 | } |
| 904 | |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 905 | ifmsh->last_preq = jiffies; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 906 | |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 907 | if (time_after(jiffies, ifmsh->last_sn_update + |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 908 | net_traversal_jiffies(sdata)) || |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 909 | time_before(jiffies, ifmsh->last_sn_update)) { |
| 910 | ++ifmsh->sn; |
| 911 | sdata->u.mesh.last_sn_update = jiffies; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 912 | } |
| 913 | lifetime = default_lifetime(sdata); |
Javier Cardona | 45904f2 | 2010-12-03 09:20:40 +0100 | [diff] [blame] | 914 | ttl = sdata->u.mesh.mshcfg.element_ttl; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 915 | if (ttl == 0) { |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 916 | sdata->u.mesh.mshstats.dropped_frames_ttl++; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 917 | spin_unlock_bh(&mpath->state_lock); |
| 918 | goto enddiscovery; |
| 919 | } |
| 920 | |
| 921 | if (preq_node->flags & PREQ_Q_F_REFRESH) |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 922 | target_flags = MP_F_DO; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 923 | else |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 924 | target_flags = MP_F_RF; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 925 | |
| 926 | spin_unlock_bh(&mpath->state_lock); |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 927 | mesh_path_sel_frame_tx(MPATH_PREQ, 0, sdata->vif.addr, |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 928 | cpu_to_le32(ifmsh->sn), target_flags, mpath->dst, |
Johannes Berg | 15ff636 | 2009-11-17 13:34:04 +0100 | [diff] [blame] | 929 | cpu_to_le32(mpath->sn), broadcast_addr, 0, |
Luis Carlos Cobo | aa2b592 | 2008-02-29 14:30:32 -0800 | [diff] [blame] | 930 | ttl, cpu_to_le32(lifetime), 0, |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 931 | cpu_to_le32(ifmsh->preq_id++), sdata); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 932 | mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout); |
| 933 | |
| 934 | enddiscovery: |
| 935 | rcu_read_unlock(); |
| 936 | kfree(preq_node); |
| 937 | } |
| 938 | |
| 939 | /** |
Rami Rosen | 2182b83 | 2009-01-19 13:50:37 +0200 | [diff] [blame] | 940 | * mesh_nexthop_lookup - put the appropriate next hop on a mesh frame |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 941 | * |
Luis Carlos Cobo | e32f85f | 2008-08-05 19:34:52 +0200 | [diff] [blame] | 942 | * @skb: 802.11 frame to be sent |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 943 | * @sdata: network subif the frame will be sent through |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 944 | * |
| 945 | * Returns: 0 if the next hop was found. Nonzero otherwise. If no next hop is |
| 946 | * found, the function will start a path discovery and queue the frame so it is |
| 947 | * sent when the path is resolved. This means the caller must not free the skb |
| 948 | * in this case. |
| 949 | */ |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 950 | int mesh_nexthop_lookup(struct sk_buff *skb, |
| 951 | struct ieee80211_sub_if_data *sdata) |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 952 | { |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 953 | struct sk_buff *skb_to_free = NULL; |
| 954 | struct mesh_path *mpath; |
Johannes Berg | 40b275b | 2011-05-13 14:15:49 +0200 | [diff] [blame] | 955 | struct sta_info *next_hop; |
Luis Carlos Cobo | e32f85f | 2008-08-05 19:34:52 +0200 | [diff] [blame] | 956 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 957 | u8 *target_addr = hdr->addr3; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 958 | int err = 0; |
| 959 | |
| 960 | rcu_read_lock(); |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 961 | mpath = mesh_path_lookup(target_addr, sdata); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 962 | |
| 963 | if (!mpath) { |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 964 | mesh_path_add(target_addr, sdata); |
| 965 | mpath = mesh_path_lookup(target_addr, sdata); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 966 | if (!mpath) { |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 967 | sdata->u.mesh.mshstats.dropped_frames_no_route++; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 968 | err = -ENOSPC; |
| 969 | goto endlookup; |
| 970 | } |
| 971 | } |
| 972 | |
| 973 | if (mpath->flags & MESH_PATH_ACTIVE) { |
Joe Perches | f64f9e7 | 2009-11-29 16:55:45 -0800 | [diff] [blame] | 974 | if (time_after(jiffies, |
Javier Cardona | 7b324d2 | 2009-12-09 18:43:01 -0800 | [diff] [blame] | 975 | mpath->exp_time - |
Joe Perches | f64f9e7 | 2009-11-29 16:55:45 -0800 | [diff] [blame] | 976 | msecs_to_jiffies(sdata->u.mesh.mshcfg.path_refresh_time)) && |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 977 | !memcmp(sdata->vif.addr, hdr->addr4, ETH_ALEN) && |
Joe Perches | f64f9e7 | 2009-11-29 16:55:45 -0800 | [diff] [blame] | 978 | !(mpath->flags & MESH_PATH_RESOLVING) && |
| 979 | !(mpath->flags & MESH_PATH_FIXED)) { |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 980 | mesh_queue_preq(mpath, |
| 981 | PREQ_Q_F_START | PREQ_Q_F_REFRESH); |
| 982 | } |
Johannes Berg | 40b275b | 2011-05-13 14:15:49 +0200 | [diff] [blame] | 983 | next_hop = rcu_dereference(mpath->next_hop); |
| 984 | if (next_hop) |
| 985 | memcpy(hdr->addr1, next_hop->sta.addr, ETH_ALEN); |
| 986 | else |
| 987 | err = -ENOENT; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 988 | } else { |
Javier Cardona | 249b405 | 2009-07-07 10:55:03 -0700 | [diff] [blame] | 989 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 990 | if (!(mpath->flags & MESH_PATH_RESOLVING)) { |
| 991 | /* Start discovery only if it is not running yet */ |
| 992 | mesh_queue_preq(mpath, PREQ_Q_F_START); |
| 993 | } |
| 994 | |
| 995 | if (skb_queue_len(&mpath->frame_queue) >= |
Javier Cardona | fe58343 | 2009-08-10 12:15:46 -0700 | [diff] [blame] | 996 | MESH_FRAME_QUEUE_LEN) |
| 997 | skb_to_free = skb_dequeue(&mpath->frame_queue); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 998 | |
Javier Cardona | 249b405 | 2009-07-07 10:55:03 -0700 | [diff] [blame] | 999 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 1000 | skb_queue_tail(&mpath->frame_queue, skb); |
| 1001 | if (skb_to_free) |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 1002 | mesh_path_discard_frame(skb_to_free, sdata); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 1003 | err = -ENOENT; |
| 1004 | } |
| 1005 | |
| 1006 | endlookup: |
| 1007 | rcu_read_unlock(); |
| 1008 | return err; |
| 1009 | } |
| 1010 | |
| 1011 | void mesh_path_timer(unsigned long data) |
| 1012 | { |
Johannes Berg | dea4096 | 2011-05-12 15:03:32 +0200 | [diff] [blame] | 1013 | struct mesh_path *mpath = (void *) data; |
| 1014 | struct ieee80211_sub_if_data *sdata = mpath->sdata; |
Javier Cardona | 5ee68e5 | 2011-08-09 16:45:08 -0700 | [diff] [blame] | 1015 | int ret; |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 1016 | |
Johannes Berg | dea4096 | 2011-05-12 15:03:32 +0200 | [diff] [blame] | 1017 | if (sdata->local->quiescing) |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 1018 | return; |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 1019 | |
| 1020 | spin_lock_bh(&mpath->state_lock); |
Luis Carlos Cobo | cfa22c7 | 2008-02-29 15:04:13 -0800 | [diff] [blame] | 1021 | if (mpath->flags & MESH_PATH_RESOLVED || |
Javier Cardona | 5ee68e5 | 2011-08-09 16:45:08 -0700 | [diff] [blame] | 1022 | (!(mpath->flags & MESH_PATH_RESOLVING))) { |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 1023 | mpath->flags &= ~(MESH_PATH_RESOLVING | MESH_PATH_RESOLVED); |
Javier Cardona | 5ee68e5 | 2011-08-09 16:45:08 -0700 | [diff] [blame] | 1024 | spin_unlock_bh(&mpath->state_lock); |
| 1025 | } else if (mpath->discovery_retries < max_preq_retries(sdata)) { |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 1026 | ++mpath->discovery_retries; |
| 1027 | mpath->discovery_timeout *= 2; |
Javier Cardona | 5ee68e5 | 2011-08-09 16:45:08 -0700 | [diff] [blame] | 1028 | spin_unlock_bh(&mpath->state_lock); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 1029 | mesh_queue_preq(mpath, 0); |
| 1030 | } else { |
| 1031 | mpath->flags = 0; |
| 1032 | mpath->exp_time = jiffies; |
Javier Cardona | 5ee68e5 | 2011-08-09 16:45:08 -0700 | [diff] [blame] | 1033 | spin_unlock_bh(&mpath->state_lock); |
| 1034 | if (!mpath->is_gate && mesh_gate_num(sdata) > 0) { |
| 1035 | ret = mesh_path_send_to_gates(mpath); |
| 1036 | if (ret) |
| 1037 | mhwmp_dbg("no gate was reachable"); |
| 1038 | } else |
| 1039 | mesh_path_flush_pending(mpath); |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 1040 | } |
Luis Carlos Cobo | 050ac52 | 2008-02-23 15:17:15 +0100 | [diff] [blame] | 1041 | } |
Rui Paulo | e304bfd | 2009-11-09 23:46:56 +0000 | [diff] [blame] | 1042 | |
| 1043 | void |
| 1044 | mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata) |
| 1045 | { |
| 1046 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
Javier Cardona | 0507e15 | 2011-08-09 16:45:10 -0700 | [diff] [blame^] | 1047 | u32 interval = ifmsh->mshcfg.dot11MeshHWMPRannInterval; |
Rui Paulo | e304bfd | 2009-11-09 23:46:56 +0000 | [diff] [blame] | 1048 | |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 1049 | mesh_path_sel_frame_tx(MPATH_RANN, 0, sdata->vif.addr, |
Rui Paulo | e304bfd | 2009-11-09 23:46:56 +0000 | [diff] [blame] | 1050 | cpu_to_le32(++ifmsh->sn), |
Johannes Berg | 15ff636 | 2009-11-17 13:34:04 +0100 | [diff] [blame] | 1051 | 0, NULL, 0, broadcast_addr, |
Javier Cardona | 45904f2 | 2010-12-03 09:20:40 +0100 | [diff] [blame] | 1052 | 0, sdata->u.mesh.mshcfg.element_ttl, |
Javier Cardona | 0507e15 | 2011-08-09 16:45:10 -0700 | [diff] [blame^] | 1053 | cpu_to_le32(interval), 0, 0, sdata); |
Rui Paulo | e304bfd | 2009-11-09 23:46:56 +0000 | [diff] [blame] | 1054 | } |