[Prism54-devel] bitrate controll & playing with oids

Luis R. Rodriguez mcgrof@ruslug.rutgers.edu
Thu, 19 Feb 2004 22:42:56 -0500


--VuQYccsttdhdIfIP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable


This too. Thanks,

	Luis

On Fri, Feb 20, 2004 at 12:52:57AM +0100, Feyd wrote:
> Hi,
>=20
> the first attached patch implements bitrate controll, the second implemen=
ts
> oid settings by iwpriv.
>=20
> Feyd

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

> diff -urNd prism54-cvs-latest-orig/ksrc/isl_ioctl.c prism54-cvs-latest/ks=
rc/isl_ioctl.c
> --- prism54-cvs-latest-orig/ksrc/isl_ioctl.c	2004-02-04 17:30:13.00000000=
0 +0100
> +++ prism54-cvs-latest/ksrc/isl_ioctl.c	2004-02-19 13:11:45.000000000 +01=
00
> +int
> +prism54_oid(struct net_device *ndev, struct iw_request_info *info,
> +		__u32 *uwrq, char *extra)
> +{
> +	islpci_private *priv =3D ndev->priv;
> +=09
> +	priv->priv_oid =3D *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 =3D ndev->priv;
> +	struct islpci_mgmtframe *response =3D NULL;
> +	int ret =3D -EIO, response_op =3D PIMFOR_OP_ERROR;
> +=09
> +	printk("prism54: get_oid 0x%08X\n", priv->priv_oid);
> +	data->length =3D 0;
> +=09
> +	if (islpci_get_state(priv) >=3D PRV_STATE_INIT) {
> +		ret =3D islpci_mgt_transaction(priv->ndev, PIMFOR_OP_GET, priv->priv_o=
id, extra, 256, &response);
> +		response_op =3D response->header->operation;
> +		printk("prism54: ret: %i\n", ret);
> +		printk("prism54: response_op: %i\n", response_op);
> +		if (ret || !response || response->header->operation =3D=3D PIMFOR_OP_E=
RROR) {
> +			if (response) {
> +				islpci_mgt_release(response);
> +			}
> +			printk("prism54: EIO\n");
> +			ret =3D -EIO;
> +		}
> +		if (!ret) {
> +			data->length =3D response->header->length;
> +			memcpy(extra, response->data, data->length);
> +			islpci_mgt_release(response);
> +			printk("prism54: len: %i\n", data->length);
> +		}
> +	}
> +=09
> +	return ret;
> +}
> +
> +int
> +prism54_set_oid(struct net_device *ndev, struct iw_request_info *info,
> +		struct iw_point *data, char *extra)
> +{
> +	islpci_private *priv =3D ndev->priv;
> +	struct islpci_mgmtframe *response =3D NULL;
> +	int ret =3D 0, response_op =3D PIMFOR_OP_ERROR;
> +=09
> +	printk("prism54: set_oid 0x%08X\tlen: %d\n", priv->priv_oid, data->leng=
th);
> +=09
> +	if (islpci_get_state(priv) >=3D PRV_STATE_INIT) {
> +		ret =3D islpci_mgt_transaction(priv->ndev, PIMFOR_OP_SET, priv->priv_o=
id, extra, data->length, &response);
> +		printk("prism54: ret: %i\n", ret);
> +		if (!ret) {
> +			response_op =3D response->header->operation;
> +			printk("prism54: response_op: %i\n", response_op);
> +			islpci_mgt_release(response);
> +		}
> +		if (ret || response_op =3D=3D PIMFOR_OP_ERROR) {
> +			printk("prism54: EIO\n");
> +		        ret =3D -EIO;
> +		}
> +	}
> +=09
> +	return ret;
> +}
> +
>  #if WIRELESS_EXT > 12
> =20
>  static const iw_handler prism54_handler[] =3D {
> @@ -1988,6 +2062,10 @@
>  #define PRISM54_GET_WPA	   SIOCIWFIRSTPRIV+13
>  #define PRISM54_SET_WPA	   SIOCIWFIRSTPRIV+14
> =20
> +#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[] =3D {
>  /*{ 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"},
>  };
> =20
>  static const iw_handler prism54_private_handler[] =3D {
> @@ -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,
>  };
> =20
>  const struct iw_handler_def prism54_handler_def =3D {
> diff -urNd prism54-cvs-latest-orig/ksrc/islpci_dev.h prism54-cvs-latest/k=
src/islpci_dev.h
> --- prism54-cvs-latest-orig/ksrc/islpci_dev.h	2004-02-03 00:06:18.0000000=
00 +0100
> +++ prism54-cvs-latest/ksrc/islpci_dev.h	2004-02-19 01:19:47.000000000 +0=
100
> @@ -94,6 +94,8 @@
> =20
>  typedef struct {
>  	spinlock_t slock;	/* generic spinlock; */
> +=09
> +	u32 priv_oid;
> =20
>  	/* our mib cache */
>  	u32 iw_mode;

> #!/bin/sh
>=20
> iwpriv $1 oid $2
> iwpriv $1 get_oid

> #!/bin/sh
>=20
> args=3D`echo $@ | cut -d" " -f3-`
>=20
> iwpriv $1 oid $2
> iwpriv $1 set_oid $args


--=20
Key fingerprint =3D 113F B290 C6D2 0251 4D84  A34A 6ADD 4937 E20A 525E

--VuQYccsttdhdIfIP
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFANYJAat1JN+IKUl4RAq/WAJwOUrb9q0/RyLAsG7NefOyg66YxRQCfcbhf
JPyILOgw6PYzd/OSS1A8Rp8=
=ehlR
-----END PGP SIGNATURE-----

--VuQYccsttdhdIfIP--