Skip to contentSkip to conversation

b43: Accessing the TSF via mac80211

PATCH In review Alina Friedrichsen 2 participants 4 messages Jan 25, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 b43: Accessing the TSF via mac80211

This allows the mac80211 high level code to access the TSF. This is e.g= =2E needed for BSSID merges in the IBSS mode.

---
diff -urN wireless-testing.orig/drivers/net/wireless/b43/main.c wireles= s-testing/drivers/net/wireless/b43/main.c
--- wireless-testing.orig/drivers/net/wireless/b43/main.c 2009-01-25 06=
:12:13.000000000 +0100
+++ wireless-testing/drivers/net/wireless/b43/main.c 2009-01-25 13:09:3=
5.000000000 +0100
@@ -3177,6 +3177,25 @@
return 0;
}
=20
+static u64 b43_op_get_tsf(struct ieee80211_hw *hw)
+{
+ struct b43_wl *wl =3D hw_to_b43_wl(hw);
+ struct b43_wldev *dev =3D wl->current_dev;
+ u64 tsf;
+
+ b43_tsf_read(dev, &tsf);
+
+ return tsf;
+}
+
+static void b43_op_set_tsf(struct ieee80211_hw *hw, u64 tsf) +{
+ struct b43_wl *wl =3D hw_to_b43_wl(hw);
+ struct b43_wldev *dev =3D wl->current_dev;
+
+ b43_tsf_write(dev, tsf);
+}
+
static void b43_put_phy_into_reset(struct b43_wldev *dev)
{
struct ssb_device *sdev =3D dev->dev;
@@ -4296,6 +4315,8 @@
.set_key =3D b43_op_set_key,
.get_stats =3D b43_op_get_stats,
.get_tx_stats =3D b43_op_get_tx_stats,
+ .get_tsf =3D b43_op_get_tsf,
+ .set_tsf =3D b43_op_set_tsf,
.start =3D b43_op_start,
.stop =3D b43_op_stop,
.set_tim =3D b43_op_beacon_set_tim,

--=20
Psssst! Schon vom neuen GMX MultiMessenger geh=F6rt? Der kann`s mit all=
en: http://www.gmx.net/de/go/multimessenger
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles= s" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#1 lore raw
Quoted 1 line · On Sunday 25 January 2009 13:41:51 Alina Friedrichsen wrote:

This allows the mac80211 high level code to access the TSF. This is e.g. needed for BSSID merges in the IBSS mode.

Thanks, can you also remove our private debugfs hook?

Quoted 6 lines

---
diff -urN wireless-testing.orig/drivers/net/wireless/b43/main.c wireless-testing/drivers/net/wireless/b43/main.c

drivers/net/wireless/b43/main.c line 3185

Quoted 9 lines
drivers/net/wireless/b43/main.c +6 -0
@@ -3177,6 +3177,25 @@
 	return 0;
 }
 
+static u64 b43_op_get_tsf(struct ieee80211_hw *hw)
+{
+	struct b43_wl *wl = hw_to_b43_wl(hw);
+	struct b43_wldev *dev = wl->current_dev;
+	u64 tsf;
+

You must add a check and locking here.

	if (dev && (b43_status(dev) >= B43_STAT_INITIALIZED)) {
		mutex_lock(&wl->mutex);
		spin_lock_irq(&wl->irq_lock);

drivers/net/wireless/b43/main.c line 3186

Quoted 1 line
drivers/net/wireless/b43/main.c +1 -0
+	b43_tsf_read(dev, &tsf);
		spin_unlock_irq(&wl->irq_lock);
		mutex_unlock(&wl->mutex);
	} else
		tsf = 0; //FIXME what to do on error?

drivers/net/wireless/b43/main.c line 3193

Quoted 7 lines
drivers/net/wireless/b43/main.c +7 -0
+	return tsf;
+}
+
+static void b43_op_set_tsf(struct ieee80211_hw *hw, u64 tsf)
+{
+	struct b43_wl *wl = hw_to_b43_wl(hw);
+	struct b43_wldev *dev = wl->current_dev;

Same check and locking goes here.

Quoted 16 lines
drivers/net/wireless/b43/main.c +5 -0
+	b43_tsf_write(dev, tsf);
+}
+
 static void b43_put_phy_into_reset(struct b43_wldev *dev)
 {
 	struct ssb_device *sdev = dev->dev;
@@ -4296,6 +4315,8 @@
 	.set_key		= b43_op_set_key,
 	.get_stats		= b43_op_get_stats,
 	.get_tx_stats		= b43_op_get_tx_stats,
+	.get_tsf		= b43_op_get_tsf,
+	.set_tsf		= b43_op_set_tsf,
 	.start			= b43_op_start,
 	.stop			= b43_op_stop,
 	.set_tim		= b43_op_beacon_set_tim,
Signature · 1 line
Greetings, Michael.
#2 lore raw
Quoted 34 lines · On Sunday 25 January 2009 13:51:50 Michael Buesch wrote:
Quoted 1 line · On Sunday 25 January 2009 13:41:51 Alina Friedrichsen wrote:

This allows the mac80211 high level code to access the TSF. This is e.g. needed for BSSID merges in the IBSS mode.

Thanks, can you also remove our private debugfs hook?

Quoted 6 lines

---
diff -urN wireless-testing.orig/drivers/net/wireless/b43/main.c wireless-testing/drivers/net/wireless/b43/main.c

drivers/net/wireless/b43/main.c line 3185

Quoted 9 lines
drivers/net/wireless/b43/main.c +6 -0
@@ -3177,6 +3177,25 @@
 	return 0;
 }
 
+static u64 b43_op_get_tsf(struct ieee80211_hw *hw)
+{
+	struct b43_wl *wl = hw_to_b43_wl(hw);
+	struct b43_wldev *dev = wl->current_dev;
+	u64 tsf;
+

You must add a check and locking here.

	if (dev && (b43_status(dev) >= B43_STAT_INITIALIZED)) {
		mutex_lock(&wl->mutex);
		spin_lock_irq(&wl->irq_lock);

drivers/net/wireless/b43/main.c line 3186

Quoted 1 line
drivers/net/wireless/b43/main.c +1 -0
+	b43_tsf_read(dev, &tsf);
		spin_unlock_irq(&wl->irq_lock);
		mutex_unlock(&wl->mutex);
	} else
		tsf = 0; //FIXME what to do on error?
Quoted 2 lines

drivers/net/wireless/b43/main.c line 3188

Quoted 2 lines
drivers/net/wireless/b43/main.c +2 -0
+	return tsf;
+}

Whoops, I got it wrong :D
This is what it should look like:

static u64 b43_op_get_tsf(struct ieee80211_hw *hw)

{
       struct b43_wl *wl = hw_to_b43_wl(hw);
       struct b43_wldev *dev = wl->current_dev;
       u64 tsf;

	mutex_lock(&wl->mutex);
	spin_lock_irq(&wl->irq_lock);
	if (dev && (b43_status(dev) >= B43_STAT_INITIALIZED))
		b43_tsf_read(dev, &tsf);
	else
		tsf = 0;//FIXME? what to do on error?
	spin_unlock_irq(&wl->irq_lock);
	mutex_unlock(&wl->mutex);

       return tsf;
}
Signature · 1 line
Greetings, Michael.
#3 lore raw
Quoted 42 lines · On Sunday 25 January 2009 13:55:49 Michael Buesch wrote:
Quoted 34 lines · On Sunday 25 January 2009 13:51:50 Michael Buesch wrote:
Quoted 1 line · On Sunday 25 January 2009 13:41:51 Alina Friedrichsen wrote:

This allows the mac80211 high level code to access the TSF. This is e.g. needed for BSSID merges in the IBSS mode.

Thanks, can you also remove our private debugfs hook?

Quoted 6 lines

---
diff -urN wireless-testing.orig/drivers/net/wireless/b43/main.c wireless-testing/drivers/net/wireless/b43/main.c

drivers/net/wireless/b43/main.c line 3185

Quoted 9 lines
drivers/net/wireless/b43/main.c +6 -0
@@ -3177,6 +3177,25 @@
 	return 0;
 }
 
+static u64 b43_op_get_tsf(struct ieee80211_hw *hw)
+{
+	struct b43_wl *wl = hw_to_b43_wl(hw);
+	struct b43_wldev *dev = wl->current_dev;
+	u64 tsf;
+

You must add a check and locking here.

	if (dev && (b43_status(dev) >= B43_STAT_INITIALIZED)) {
		mutex_lock(&wl->mutex);
		spin_lock_irq(&wl->irq_lock);

drivers/net/wireless/b43/main.c line 3186

Quoted 1 line
drivers/net/wireless/b43/main.c +1 -0
+	b43_tsf_read(dev, &tsf);
		spin_unlock_irq(&wl->irq_lock);
		mutex_unlock(&wl->mutex);
	} else
		tsf = 0; //FIXME what to do on error?
Quoted 2 lines

drivers/net/wireless/b43/main.c line 3188

Quoted 2 lines
drivers/net/wireless/b43/main.c +2 -0
+	return tsf;
+}

Whoops, I got it wrong :D
This is what it should look like:

static u64 b43_op_get_tsf(struct ieee80211_hw *hw)

Quoted 17 lines
{
       struct b43_wl *wl = hw_to_b43_wl(hw);
       struct b43_wldev *dev = wl->current_dev;
       u64 tsf;

	mutex_lock(&wl->mutex);
	spin_lock_irq(&wl->irq_lock);
	if (dev && (b43_status(dev) >= B43_STAT_INITIALIZED))
		b43_tsf_read(dev, &tsf);
	else
		tsf = 0;//FIXME? what to do on error?
	spin_unlock_irq(&wl->irq_lock);
	mutex_unlock(&wl->mutex);

       return tsf;
}

Damn, I'm not awake, yet.
The dev = wl->current_dev also must be inside of the mutex.

Signature · 1 line
Greetings, Michael.