[Prism54-devel] bitrate controll & playing with oids

Feyd feyd@seznam.cz
Fri, 20 Feb 2004 00:52:57 +0100


This is a multi-part message in MIME format.

--Multipart=_Fri__20_Feb_2004_00_52_57_+0100_md0plWFQ9UXfxnV.
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

Hi,

the first attached patch implements bitrate controll, the second implements
oid settings by iwpriv.

Feyd

--Multipart=_Fri__20_Feb_2004_00_52_57_+0100_md0plWFQ9UXfxnV.
Content-Type: text/plain;
 name="rate.diff"
Content-Disposition: attachment;
 filename="rate.diff"
Content-Transfer-Encoding: 7bit

diff -urNd prism54-cvs-latest-orig/ksrc/isl_ioctl.c prism54-cvs-latest/ksrc/isl_ioctl.c
--- prism54-cvs-latest-orig/ksrc/isl_ioctl.c	2004-02-04 17:30:13.000000000 +0100
+++ prism54-cvs-latest/ksrc/isl_ioctl.c	2004-02-20 00:38:09.000000000 +0100
@@ -845,7 +845,7 @@
 	return 0;
 }
 
-/* Set the allowed Bitrates - BROKEN - disabled */
+/* Set the allowed Bitrates */
 
 static int
 prism54_set_rate(struct net_device *ndev,
@@ -853,30 +853,66 @@
 		 struct iw_param *vwrq, char *extra)
 {
 
-/*	islpci_private *priv = ndev->priv; */
-	u32 rate;
-
-	if ((vwrq->value < 8) && (vwrq->value >= 0))
-		/* it is a rate index */
-		rate = vwrq->value;
-	else
-		rate = (u32) (vwrq->value / 500000);
-
+	islpci_private *priv = ndev->priv;
+	u32 rate, profile;
+	char *data;
+	int ret, i;
+	union oid_res_t r;
+	
 	if (vwrq->value == -1) {
 		/* auto mode. No limit. */
-
+		profile = 1;
+		return mgt_set_request(priv, DOT11_OID_PROFILES, 0, &profile);
 	}
-
+	
+	if((ret = mgt_get_request(priv, DOT11_OID_SUPPORTEDRATES, 0, NULL, &r)))
+		return ret;
+		
+	rate = (u32) (vwrq->value / 500000);
+	data = r.ptr;
+	i = 0;
+	
+	while(data[i]) {
+		if(rate && (data[i] == rate)) {
+			break;
+		}
+		if(vwrq->value == i) {
+			break;
+		}
+		data[i] |= 0x80;
+		i++;
+	}
+		
+	if(!data[i]) {
+		return -EINVAL;
+	}
+	
+	data[i] |= 0x80;
+	data[i + 1] = 0;
+	
 	/* Now, check if we want a fixed or auto value */
-	if (vwrq->fixed == 0) {
-		/* set the maximum allowed bitrate */
-
-	} else {
-		/* Fixed rate  mode */
-
+	if (vwrq->fixed) {
+		data[0] = data[i];
+		data[1] = 0;
 	}
 
-	return 0;
+/*
+	i = 0;
+	printk("prism54 rate: ");
+	while(data[i]) {
+		printk("%u ", data[i]);
+		i++;
+	}
+	printk("0\n");
+*/	
+	profile = -1;
+	ret = mgt_set_request(priv, DOT11_OID_PROFILES, 0, &profile);
+	ret |= mgt_set_request(priv, DOT11_OID_EXTENDEDRATES, 0, data);
+	ret |= mgt_set_request(priv, DOT11_OID_RATES, 0, data);
+	
+	kfree(r.ptr);
+	
+	return ret;
 }
 
 /* Get the current bit rate */
@@ -887,19 +923,22 @@
 {
 	islpci_private *priv = ndev->priv;
 	int rvalue;
+	char *data;
 	union oid_res_t r;
 
 	/* Get the current bit rate */
-	rvalue = mgt_get_request(priv, GEN_OID_LINKSTATE, 0, NULL, &r);
+	if((rvalue = mgt_get_request(priv, GEN_OID_LINKSTATE, 0, NULL, &r)))
+		return rvalue;
 	vwrq->value = r.u * 500000;
 
-	/* request the device for the fixed rate */
-	rvalue |= mgt_get_request(priv, DOT11_OID_ALOFT_FIXEDRATE, 0, NULL, &r);
-
-	/* if *data = -1 we are not in fixed rate mode. Report it. */
-	vwrq->fixed = (r.u != -1);
-
-	return rvalue;
+	/* request the device for the enabled rates */
+	if((rvalue = mgt_get_request(priv, DOT11_OID_RATES, 0, NULL, &r)))
+		return rvalue;
+	data = r.ptr;
+	vwrq->fixed = (data[0] != 0) && (data[1] == 0);
+	kfree(r.ptr);
+	
+	return 0;
 }
 
 static int
@@ -1953,7 +1992,7 @@
 	(iw_handler) prism54_get_nick,	/* SIOCGIWNICKN */
 	(iw_handler) NULL,	/* -- hole -- */
 	(iw_handler) NULL,	/* -- hole -- */
-	(iw_handler) NULL,	/* SIOCSIWRATE */
+	(iw_handler) prism54_set_rate,	/* SIOCSIWRATE */
 	(iw_handler) prism54_get_rate,	/* SIOCGIWRATE */
 	(iw_handler) prism54_set_rts,	/* SIOCSIWRTS */
 	(iw_handler) prism54_get_rts,	/* SIOCGIWRTS */

--Multipart=_Fri__20_Feb_2004_00_52_57_+0100_md0plWFQ9UXfxnV.
Content-Type: text/plain;
 name="oid.diff"
Content-Disposition: attachment;
 filename="oid.diff"
Content-Transfer-Encoding: 7bit

diff -urNd prism54-cvs-latest-orig/ksrc/isl_ioctl.c prism54-cvs-latest/ksrc/isl_ioctl.c
--- prism54-cvs-latest-orig/ksrc/isl_ioctl.c	2004-02-04 17:30:13.000000000 +0100
+++ prism54-cvs-latest/ksrc/isl_ioctl.c	2004-02-19 13:11:45.000000000 +0100
+int
+prism54_oid(struct net_device *ndev, struct iw_request_info *info,
+		__u32 *uwrq, char *extra)
+{
+	islpci_private *priv = ndev->priv;
+	
+	priv->priv_oid = *uwrq;
+	printk("prism54: oid 0x%08X\n", *uwrq);
+
+	return 0;
+}
+
+int
+prism54_get_oid(struct net_device *ndev, struct iw_request_info *info,
+		struct iw_point *data, char *extra)
+{
+	islpci_private *priv = ndev->priv;
+	struct islpci_mgmtframe *response = NULL;
+	int ret = -EIO, response_op = PIMFOR_OP_ERROR;
+	
+	printk("prism54: get_oid 0x%08X\n", priv->priv_oid);
+	data->length = 0;
+	
+	if (islpci_get_state(priv) >= PRV_STATE_INIT) {
+		ret = islpci_mgt_transaction(priv->ndev, PIMFOR_OP_GET, priv->priv_oid, extra, 256, &response);
+		response_op = response->header->operation;
+		printk("prism54: ret: %i\n", ret);
+		printk("prism54: response_op: %i\n", response_op);
+		if (ret || !response || response->header->operation == PIMFOR_OP_ERROR) {
+			if (response) {
+				islpci_mgt_release(response);
+			}
+			printk("prism54: EIO\n");
+			ret = -EIO;
+		}
+		if (!ret) {
+			data->length = response->header->length;
+			memcpy(extra, response->data, data->length);
+			islpci_mgt_release(response);
+			printk("prism54: len: %i\n", data->length);
+		}
+	}
+	
+	return ret;
+}
+
+int
+prism54_set_oid(struct net_device *ndev, struct iw_request_info *info,
+		struct iw_point *data, char *extra)
+{
+	islpci_private *priv = ndev->priv;
+	struct islpci_mgmtframe *response = NULL;
+	int ret = 0, response_op = PIMFOR_OP_ERROR;
+	
+	printk("prism54: set_oid 0x%08X\tlen: %d\n", priv->priv_oid, data->length);
+	
+	if (islpci_get_state(priv) >= PRV_STATE_INIT) {
+		ret = islpci_mgt_transaction(priv->ndev, PIMFOR_OP_SET, priv->priv_oid, extra, data->length, &response);
+		printk("prism54: ret: %i\n", ret);
+		if (!ret) {
+			response_op = response->header->operation;
+			printk("prism54: response_op: %i\n", response_op);
+			islpci_mgt_release(response);
+		}
+		if (ret || response_op == PIMFOR_OP_ERROR) {
+			printk("prism54: EIO\n");
+		        ret = -EIO;
+		}
+	}
+	
+	return ret;
+}
+
 #if WIRELESS_EXT > 12
 
 static const iw_handler prism54_handler[] = {
@@ -1988,6 +2062,10 @@
 #define PRISM54_GET_WPA	   SIOCIWFIRSTPRIV+13
 #define PRISM54_SET_WPA	   SIOCIWFIRSTPRIV+14
 
+#define PRISM54_OID	   SIOCIWFIRSTPRIV+16
+#define PRISM54_GET_OID	   SIOCIWFIRSTPRIV+17
+#define PRISM54_SET_OID	   SIOCIWFIRSTPRIV+18
+
 static const struct iw_priv_args prism54_private_args[] = {
 /*{ cmd, set_args, get_args, name } */
 	{PRISM54_RESET, 0, 0, "reset"},
@@ -2011,6 +2089,9 @@
 	 "get_wpa"},
 	{PRISM54_SET_WPA, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
 	 "set_wpa"},
+	{PRISM54_OID, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "oid"},
+	{PRISM54_GET_OID, 0, IW_PRIV_TYPE_BYTE | 256, "get_oid"},
+	{PRISM54_SET_OID, IW_PRIV_TYPE_BYTE | 256, 0, "set_oid"},
 };
 
 static const iw_handler prism54_private_handler[] = {
@@ -2029,6 +2110,10 @@
 	(iw_handler) prism54_kick_all,
 	(iw_handler) prism54_get_wpa,
 	(iw_handler) prism54_set_wpa,
+	(iw_handler) NULL,
+	(iw_handler) prism54_oid,
+	(iw_handler) prism54_get_oid,
+	(iw_handler) prism54_set_oid,
 };
 
 const struct iw_handler_def prism54_handler_def = {
diff -urNd prism54-cvs-latest-orig/ksrc/islpci_dev.h prism54-cvs-latest/ksrc/islpci_dev.h
--- prism54-cvs-latest-orig/ksrc/islpci_dev.h	2004-02-03 00:06:18.000000000 +0100
+++ prism54-cvs-latest/ksrc/islpci_dev.h	2004-02-19 01:19:47.000000000 +0100
@@ -94,6 +94,8 @@
 
 typedef struct {
 	spinlock_t slock;	/* generic spinlock; */
+	
+	u32 priv_oid;
 
 	/* our mib cache */
 	u32 iw_mode;

--Multipart=_Fri__20_Feb_2004_00_52_57_+0100_md0plWFQ9UXfxnV.
Content-Type: text/plain;
 name="getoid"
Content-Disposition: attachment;
 filename="getoid"
Content-Transfer-Encoding: base64

IyEvYmluL3NoCgppd3ByaXYgJDEgb2lkICQyCml3cHJpdiAkMSBnZXRfb2lkCg==

--Multipart=_Fri__20_Feb_2004_00_52_57_+0100_md0plWFQ9UXfxnV.
Content-Type: text/plain;
 name="setoid"
Content-Disposition: attachment;
 filename="setoid"
Content-Transfer-Encoding: base64

IyEvYmluL3NoCgphcmdzPWBlY2hvICRAIHwgY3V0IC1kIiAiIC1mMy1gCgppd3ByaXYgJDEgb2lk
ICQyCml3cHJpdiAkMSBzZXRfb2lkICRhcmdzCg==

--Multipart=_Fri__20_Feb_2004_00_52_57_+0100_md0plWFQ9UXfxnV.--