Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 268647
b: refs/heads/master
c: 2228b27
h: refs/heads/master
i:
  268645: ee5c68a
  268643: 215d21e
  268639: 443bbf6
v: v3
  • Loading branch information
Roland Vossen authored and Greg Kroah-Hartman committed Oct 3, 2011
1 parent c175e54 commit f920aa7
Show file tree
Hide file tree
Showing 9 changed files with 234 additions and 243 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8ff3a896843aa11358f57819cc4ac001120d1331
refs/heads/master: 2228b27da6b11d748e5072f4413d512b4480d7ee
32 changes: 11 additions & 21 deletions trunk/drivers/staging/brcm80211/brcmfmac/dhd.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@

#define BRCMF_VERSION_STR "4.218.248.5"

#define BRCMF_C_IOCTL_SMLEN 256 /* "small" ioctl buffer required */
#define BRCMF_C_IOCTL_MEDLEN 1536 /* "med" ioctl buffer required */
#define BRCMF_C_IOCTL_MAXLEN 8192
#define BRCMF_C_DCMD_SMLEN 256 /* "small" cmd buffer required */
#define BRCMF_C_DCMD_MEDLEN 1536 /* "med" cmd buffer required */
#define BRCMF_C_DCMD_MAXLEN 8192

/*******************************************************************************
* IO codes that are interpreted by dongle firmware
Expand Down Expand Up @@ -572,12 +572,12 @@ struct brcmf_channel_info_le {
__le32 scan_channel;
};

/* Linux network driver ioctl encoding */
struct brcmf_ioctl {
uint cmd; /* common ioctl definition */
/* Bus independent dongle command */
struct brcmf_dcmd {
uint cmd; /* common dongle cmd definition */
void *buf; /* pointer to user buffer */
uint len; /* length of user buffer */
u8 set; /* get or set request (optional) */
u8 set; /* get or set request (optional) */
uint used; /* bytes read or written (optional) */
uint needed; /* bytes needed (optional) */
};
Expand Down Expand Up @@ -694,7 +694,7 @@ extern struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus,
extern int brcmf_net_attach(struct brcmf_pub *drvr, int idx);
extern int brcmf_netdev_wait_pend8021x(struct net_device *ndev);

extern s32 brcmf_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len);
extern s32 brcmf_exec_dcmd(struct net_device *dev, u32 cmd, void *arg, u32 len);

/* Indication from bus module regarding removal/absence of dongle */
extern void brcmf_detach(struct brcmf_pub *drvr);
Expand All @@ -716,8 +716,8 @@ extern char *brcmf_ifname(struct brcmf_pub *drvr, int idx);
extern void brcmf_txcomplete(struct brcmf_pub *drvr, struct sk_buff *txp,
bool success);

/* Query ioctl */
extern int brcmf_proto_cdc_query_ioctl(struct brcmf_pub *drvr, int ifidx,
/* Query dongle */
extern int brcmf_proto_cdc_query_dcmd(struct brcmf_pub *drvr, int ifidx,
uint cmd, void *buf, uint len);

/* OS independent layer functions */
Expand Down Expand Up @@ -749,17 +749,7 @@ extern void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg);
extern void brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg,
int enable, int master_mode);

/* per-driver magic numbers */
#define BRCMF_IOCTL_MAGIC 0x00444944

/* bump this number if you change the ioctl interface */
#define BRCMF_IOCTL_VERSION 1
#define BRCMF_IOCTL_MAXLEN 8192 /* max length ioctl buffer required */

/* common ioctl definitions */
#define BRCMF_GET_VERSION 1
#define BRCMF_GET_VAR 2
#define BRCMF_SET_VAR 3
#define BRCMF_DCMD_MAXLEN 8192 /* max length cmd buffer required */

/* message levels */
#define BRCMF_ERROR_VAL 0x0001
Expand Down
118 changes: 60 additions & 58 deletions trunk/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

/*******************************************************************************
* Communicates with the dongle by using Broadcom specific ioctl codes.
* For certain ioctl codes, the dongle interprets string data from the host.
* Communicates with the dongle by using dcmd codes.
* For certain dcmd codes, the dongle interprets string data from the host.
******************************************************************************/

#include <linux/types.h>
Expand All @@ -32,8 +32,8 @@
#include "dhd_bus.h"
#include "dhd_dbg.h"

struct brcmf_proto_cdc_ioctl {
__le32 cmd; /* ioctl command value */
struct brcmf_proto_cdc_dcmd {
__le32 cmd; /* dongle command value */
__le32 len; /* lower 16: output buflen;
* upper 16: input buflen (excludes header) */
__le32 flags; /* flag defns given below */
Expand All @@ -44,14 +44,14 @@ struct brcmf_proto_cdc_ioctl {
#define CDC_MAX_MSG_SIZE (ETH_FRAME_LEN+ETH_FCS_LEN)

/* CDC flag definitions */
#define CDCF_IOC_ERROR 0x01 /* 1=ioctl cmd failed */
#define CDCF_IOC_SET 0x02 /* 0=get, 1=set cmd */
#define CDCF_IOC_IF_MASK 0xF000 /* I/F index */
#define CDCF_IOC_IF_SHIFT 12
#define CDCF_IOC_ID_MASK 0xFFFF0000 /* id an ioctl pairing */
#define CDCF_IOC_ID_SHIFT 16 /* ID Mask shift bits */
#define CDC_IOC_ID(flags) \
(((flags) & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT)
#define CDC_DCMD_ERROR 0x01 /* 1=cmd failed */
#define CDC_DCMD_SET 0x02 /* 0=get, 1=set cmd */
#define CDC_DCMD_IF_MASK 0xF000 /* I/F index */
#define CDC_DCMD_IF_SHIFT 12
#define CDC_DCMD_ID_MASK 0xFFFF0000 /* id an cmd pairing */
#define CDC_DCMD_ID_SHIFT 16 /* ID Mask shift bits */
#define CDC_DCMD_ID(flags) \
(((flags) & CDC_DCMD_ID_MASK) >> CDC_DCMD_ID_SHIFT)

/*
* BDC header - Broadcom specific extension of CDC.
Expand Down Expand Up @@ -81,7 +81,7 @@ struct brcmf_proto_bdc_header {
};


#define RETRIES 2 /* # of retries to retrieve matching ioctl response */
#define RETRIES 2 /* # of retries to retrieve matching dcmd response */
#define BUS_HEADER_LEN (16+BRCMF_SDALIGN) /* Must be atleast SDPCM_RESERVE
* (amount of header tha might be added)
* plus any space that might be needed
Expand All @@ -96,15 +96,15 @@ struct brcmf_proto {
u8 pending;
u32 lastcmd;
u8 bus_header[BUS_HEADER_LEN];
struct brcmf_proto_cdc_ioctl msg;
unsigned char buf[BRCMF_C_IOCTL_MAXLEN + ROUND_UP_MARGIN];
struct brcmf_proto_cdc_dcmd msg;
unsigned char buf[BRCMF_C_DCMD_MAXLEN + ROUND_UP_MARGIN];
};

static int brcmf_proto_cdc_msg(struct brcmf_pub *drvr)
{
struct brcmf_proto *prot = drvr->prot;
int len = le32_to_cpu(prot->msg.len) +
sizeof(struct brcmf_proto_cdc_ioctl);
sizeof(struct brcmf_proto_cdc_dcmd);

brcmf_dbg(TRACE, "Enter\n");

Expand All @@ -130,20 +130,20 @@ static int brcmf_proto_cdc_cmplt(struct brcmf_pub *drvr, u32 id, u32 len)
do {
ret = brcmf_sdbrcm_bus_rxctl(drvr->bus,
(unsigned char *)&prot->msg,
len + sizeof(struct brcmf_proto_cdc_ioctl));
len + sizeof(struct brcmf_proto_cdc_dcmd));
if (ret < 0)
break;
} while (CDC_IOC_ID(le32_to_cpu(prot->msg.flags)) != id);
} while (CDC_DCMD_ID(le32_to_cpu(prot->msg.flags)) != id);

return ret;
}

int
brcmf_proto_cdc_query_ioctl(struct brcmf_pub *drvr, int ifidx, uint cmd,
void *buf, uint len)
brcmf_proto_cdc_query_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd,
void *buf, uint len)
{
struct brcmf_proto *prot = drvr->prot;
struct brcmf_proto_cdc_ioctl *msg = &prot->msg;
struct brcmf_proto_cdc_dcmd *msg = &prot->msg;
void *info;
int ret = 0, retries = 0;
u32 id, flags;
Expand All @@ -163,12 +163,13 @@ brcmf_proto_cdc_query_ioctl(struct brcmf_pub *drvr, int ifidx, uint cmd,
}
}

memset(msg, 0, sizeof(struct brcmf_proto_cdc_ioctl));
memset(msg, 0, sizeof(struct brcmf_proto_cdc_dcmd));

msg->cmd = cpu_to_le32(cmd);
msg->len = cpu_to_le32(len);
flags = (++prot->reqid << CDCF_IOC_ID_SHIFT);
flags = (flags & ~CDCF_IOC_IF_MASK) | (ifidx << CDCF_IOC_IF_SHIFT);
flags = (++prot->reqid << CDC_DCMD_ID_SHIFT);
flags = (flags & ~CDC_DCMD_IF_MASK) |
(ifidx << CDC_DCMD_IF_SHIFT);
msg->flags = cpu_to_le32(flags);

if (buf)
Expand All @@ -188,7 +189,7 @@ brcmf_proto_cdc_query_ioctl(struct brcmf_pub *drvr, int ifidx, uint cmd,
goto done;

flags = le32_to_cpu(msg->flags);
id = (flags & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT;
id = (flags & CDC_DCMD_ID_MASK) >> CDC_DCMD_ID_SHIFT;

if ((id < prot->reqid) && (++retries < RETRIES))
goto retry;
Expand All @@ -210,7 +211,7 @@ brcmf_proto_cdc_query_ioctl(struct brcmf_pub *drvr, int ifidx, uint cmd,
}

/* Check the ERROR flag */
if (flags & CDCF_IOC_ERROR) {
if (flags & CDC_DCMD_ERROR) {
ret = le32_to_cpu(msg->status);
/* Cache error from dongle */
drvr->dongle_error = ret;
Expand All @@ -220,23 +221,24 @@ brcmf_proto_cdc_query_ioctl(struct brcmf_pub *drvr, int ifidx, uint cmd,
return ret;
}

int brcmf_proto_cdc_set_ioctl(struct brcmf_pub *drvr, int ifidx, uint cmd,
void *buf, uint len)
int brcmf_proto_cdc_set_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd,
void *buf, uint len)
{
struct brcmf_proto *prot = drvr->prot;
struct brcmf_proto_cdc_ioctl *msg = &prot->msg;
struct brcmf_proto_cdc_dcmd *msg = &prot->msg;
int ret = 0;
u32 flags, id;

brcmf_dbg(TRACE, "Enter\n");
brcmf_dbg(CTL, "cmd %d len %d\n", cmd, len);

memset(msg, 0, sizeof(struct brcmf_proto_cdc_ioctl));
memset(msg, 0, sizeof(struct brcmf_proto_cdc_dcmd));

msg->cmd = cpu_to_le32(cmd);
msg->len = cpu_to_le32(len);
flags = (++prot->reqid << CDCF_IOC_ID_SHIFT) | CDCF_IOC_SET;
flags = (flags & ~CDCF_IOC_IF_MASK) | (ifidx << CDCF_IOC_IF_SHIFT);
flags = (++prot->reqid << CDC_DCMD_ID_SHIFT) | CDC_DCMD_SET;
flags = (flags & ~CDC_DCMD_IF_MASK) |
(ifidx << CDC_DCMD_IF_SHIFT);
msg->flags = cpu_to_le32(flags);

if (buf)
Expand All @@ -251,7 +253,7 @@ int brcmf_proto_cdc_set_ioctl(struct brcmf_pub *drvr, int ifidx, uint cmd,
goto done;

flags = le32_to_cpu(msg->flags);
id = (flags & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT;
id = (flags & CDC_DCMD_ID_MASK) >> CDC_DCMD_ID_SHIFT;

if (id != prot->reqid) {
brcmf_dbg(ERROR, "%s: unexpected request id %d (expected %d)\n",
Expand All @@ -261,7 +263,7 @@ int brcmf_proto_cdc_set_ioctl(struct brcmf_pub *drvr, int ifidx, uint cmd,
}

/* Check the ERROR flag */
if (flags & CDCF_IOC_ERROR) {
if (flags & CDC_DCMD_ERROR) {
ret = le32_to_cpu(msg->status);
/* Cache error from dongle */
drvr->dongle_error = ret;
Expand All @@ -272,7 +274,7 @@ int brcmf_proto_cdc_set_ioctl(struct brcmf_pub *drvr, int ifidx, uint cmd,
}

int
brcmf_proto_ioctl(struct brcmf_pub *drvr, int ifidx, struct brcmf_ioctl *ioc,
brcmf_proto_dcmd(struct brcmf_pub *drvr, int ifidx, struct brcmf_dcmd *dcmd,
int len)
{
struct brcmf_proto *prot = drvr->prot;
Expand All @@ -286,50 +288,50 @@ brcmf_proto_ioctl(struct brcmf_pub *drvr, int ifidx, struct brcmf_ioctl *ioc,

brcmf_dbg(TRACE, "Enter\n");

if (len > BRCMF_C_IOCTL_MAXLEN)
if (len > BRCMF_C_DCMD_MAXLEN)
goto done;

if (prot->pending == true) {
brcmf_dbg(TRACE, "CDC packet is pending!!!! cmd=0x%x (%lu) lastcmd=0x%x (%lu)\n",
ioc->cmd, (unsigned long)ioc->cmd, prot->lastcmd,
dcmd->cmd, (unsigned long)dcmd->cmd, prot->lastcmd,
(unsigned long)prot->lastcmd);
if ((ioc->cmd == BRCMF_C_SET_VAR) ||
(ioc->cmd == BRCMF_C_GET_VAR))
brcmf_dbg(TRACE, "iovar cmd=%s\n", (char *)ioc->buf);
if (dcmd->cmd == BRCMF_C_SET_VAR ||
dcmd->cmd == BRCMF_C_GET_VAR)
brcmf_dbg(TRACE, "iovar cmd=%s\n", (char *)dcmd->buf);

goto done;
}

prot->pending = true;
prot->lastcmd = ioc->cmd;
if (ioc->set)
ret = brcmf_proto_cdc_set_ioctl(drvr, ifidx, ioc->cmd,
ioc->buf, len);
prot->lastcmd = dcmd->cmd;
if (dcmd->set)
ret = brcmf_proto_cdc_set_dcmd(drvr, ifidx, dcmd->cmd,
dcmd->buf, len);
else {
ret = brcmf_proto_cdc_query_ioctl(drvr, ifidx, ioc->cmd,
ioc->buf, len);
ret = brcmf_proto_cdc_query_dcmd(drvr, ifidx, dcmd->cmd,
dcmd->buf, len);
if (ret > 0)
ioc->used = ret - sizeof(struct brcmf_proto_cdc_ioctl);
dcmd->used = ret -
sizeof(struct brcmf_proto_cdc_dcmd);
}

/* Too many programs assume ioctl() returns 0 on success */
if (ret >= 0)
ret = 0;
else {
struct brcmf_proto_cdc_ioctl *msg = &prot->msg;
struct brcmf_proto_cdc_dcmd *msg = &prot->msg;
/* len == needed when set/query fails from dongle */
ioc->needed = le32_to_cpu(msg->len);
dcmd->needed = le32_to_cpu(msg->len);
}

/* Intercept the wme_dp ioctl here */
if (!ret && ioc->cmd == BRCMF_C_SET_VAR &&
!strcmp(ioc->buf, "wme_dp")) {
/* Intercept the wme_dp dongle cmd here */
if (!ret && dcmd->cmd == BRCMF_C_SET_VAR &&
!strcmp(dcmd->buf, "wme_dp")) {
int slen;
__le32 val = 0;

slen = strlen("wme_dp") + 1;
if (len >= (int)(slen + sizeof(int)))
memcpy(&val, (char *)ioc->buf + slen, sizeof(int));
memcpy(&val, (char *)dcmd->buf + slen, sizeof(int));
drvr->wme_dp = (u8) le32_to_cpu(val);
}

Expand Down Expand Up @@ -433,8 +435,8 @@ int brcmf_proto_attach(struct brcmf_pub *drvr)

drvr->prot = cdc;
drvr->hdrlen += BDC_HEADER_LEN;
drvr->maxctl = BRCMF_C_IOCTL_MAXLEN +
sizeof(struct brcmf_proto_cdc_ioctl) + ROUND_UP_MARGIN;
drvr->maxctl = BRCMF_C_DCMD_MAXLEN +
sizeof(struct brcmf_proto_cdc_dcmd) + ROUND_UP_MARGIN;
return 0;

fail:
Expand Down Expand Up @@ -472,7 +474,7 @@ int brcmf_proto_init(struct brcmf_pub *drvr)

/* Get the device MAC address */
strcpy(buf, "cur_etheraddr");
ret = brcmf_proto_cdc_query_ioctl(drvr, 0, BRCMF_C_GET_VAR,
ret = brcmf_proto_cdc_query_dcmd(drvr, 0, BRCMF_C_GET_VAR,
buf, sizeof(buf));
if (ret < 0) {
brcmf_os_proto_unblock(drvr);
Expand All @@ -482,7 +484,7 @@ int brcmf_proto_init(struct brcmf_pub *drvr)

brcmf_os_proto_unblock(drvr);

ret = brcmf_c_preinit_ioctls(drvr);
ret = brcmf_c_preinit_dcmds(drvr);

/* Always assumes wl for now */
drvr->iswl = true;
Expand Down
Loading

0 comments on commit f920aa7

Please sign in to comment.