Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d9cb2596 authored by Arend van Spriel's avatar Arend van Spriel Committed by John W. Linville
Browse files

brcmfmac: rework bus interface



Rework the bus interface between common driver part and bus-specific
driver part. It prepares for adding tracing in bus-specific callback
functions.

Reviewed-by: default avatarPieter-Paul Giesberts <pieterpg@broadcom.com>
Reviewed-by: default avatarHante Meuleman <meuleman@broadcom.com>
Reviewed-by: default avatarFranky (Zhenhui) Lin <frankyl@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 9e2ff36b
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -470,7 +470,6 @@ struct brcmf_pub {
	struct brcmf_bus *bus_if;
	struct brcmf_proto *prot;
	struct brcmf_cfg80211_info *config;
	struct device *dev;		/* fullmac dongle device pointer */

	/* Internal brcmf items */
	uint hdrlen;		/* Total BRCMF header length (proto + bus) */
+73 −19
Original line number Diff line number Diff line
@@ -43,35 +43,89 @@ struct brcmf_bus_dcmd {
	struct list_head list;
};

/* interface structure between common and bus layer */
/**
 * struct brcmf_bus_ops - bus callback operations.
 *
 * @init: prepare for communication with dongle.
 * @stop: clear pending frames, disable data flow.
 * @txdata: send a data frame to the dongle (callee disposes skb).
 * @txctl: transmit a control request message to dongle.
 * @rxctl: receive a control response message from dongle.
 *
 * This structure provides an abstract interface towards the
 * bus specific driver. For control messages to common driver
 * will assure there is only one active transaction.
 */
struct brcmf_bus_ops {
	int (*init)(struct device *dev);
	void (*stop)(struct device *dev);
	int (*txdata)(struct device *dev, struct sk_buff *skb);
	int (*txctl)(struct device *dev, unsigned char *msg, uint len);
	int (*rxctl)(struct device *dev, unsigned char *msg, uint len);
};

/**
 * struct brcmf_bus - interface structure between common and bus layer
 *
 * @bus_priv: pointer to private bus device.
 * @dev: device pointer of bus device.
 * @drvr: public driver information.
 * @state: operational state of the bus interface.
 * @maxctl: maximum size for rxctl request message.
 * @drvr_up: indicates driver up/down status.
 * @tx_realloc: number of tx packets realloced for headroom.
 * @dstats: dongle-based statistical data.
 * @align: alignment requirement for the bus.
 * @dcmd_list: bus/device specific dongle initialization commands.
 */
struct brcmf_bus {
	union {
		struct brcmf_sdio_dev *sdio;
		struct brcmf_usbdev *usb;
	} bus_priv;
	struct brcmf_pub *drvr;	/* pointer to driver pub structure brcmf_pub */
	struct device *dev;
	struct brcmf_pub *drvr;
	enum brcmf_bus_state state;
	uint maxctl;		/* Max size rxctl request from proto to bus */
	bool drvr_up;		/* Status flag of driver up/down */
	unsigned long tx_realloc;	/* Tx packets realloced for headroom */
	struct dngl_stats dstats;	/* Stats for dongle-based data */
	u8 align;		/* bus alignment requirement */
	uint maxctl;
	bool drvr_up;
	unsigned long tx_realloc;
	struct dngl_stats dstats;
	u8 align;
	struct list_head dcmd_list;

	/* interface functions pointers */
	/* Stop bus module: clear pending frames, disable data flow */
	void (*brcmf_bus_stop)(struct device *);
	/* Initialize bus module: prepare for communication w/dongle */
	int (*brcmf_bus_init)(struct device *);
	/* Send a data frame to the dongle.  Callee disposes of txp. */
	int (*brcmf_bus_txdata)(struct device *, struct sk_buff *);
	/* Send/receive a control message to/from the dongle.
	 * Expects caller to enforce a single outstanding transaction.
	 */
	int (*brcmf_bus_txctl)(struct device *, unsigned char *, uint);
	int (*brcmf_bus_rxctl)(struct device *, unsigned char *, uint);
	struct brcmf_bus_ops *ops;
};

/*
 * callback wrappers
 */
static inline int brcmf_bus_init(struct brcmf_bus *bus)
{
	return bus->ops->init(bus->dev);
}

static inline void brcmf_bus_stop(struct brcmf_bus *bus)
{
	bus->ops->stop(bus->dev);
}

static inline int brcmf_bus_txdata(struct brcmf_bus *bus, struct sk_buff *skb)
{
	return bus->ops->txdata(bus->dev, skb);
}

static inline
int brcmf_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint len)
{
	return bus->ops->txctl(bus->dev, msg, len);
}

static inline
int brcmf_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint len)
{
	return bus->ops->rxctl(bus->dev, msg, len);
}

/*
 * interface functions from common layer
 */
+4 −7
Original line number Diff line number Diff line
@@ -117,9 +117,7 @@ static int brcmf_proto_cdc_msg(struct brcmf_pub *drvr)
		len = CDC_MAX_MSG_SIZE;

	/* Send request */
	return drvr->bus_if->brcmf_bus_txctl(drvr->dev,
					     (unsigned char *)&prot->msg,
					     len);
	return brcmf_bus_txctl(drvr->bus_if, (unsigned char *)&prot->msg, len);
}

static int brcmf_proto_cdc_cmplt(struct brcmf_pub *drvr, u32 id, u32 len)
@@ -128,11 +126,10 @@ static int brcmf_proto_cdc_cmplt(struct brcmf_pub *drvr, u32 id, u32 len)
	struct brcmf_proto *prot = drvr->prot;

	brcmf_dbg(TRACE, "Enter\n");

	len += sizeof(struct brcmf_proto_cdc_dcmd);
	do {
		ret = drvr->bus_if->brcmf_bus_rxctl(drvr->dev,
				(unsigned char *)&prot->msg,
				len + sizeof(struct brcmf_proto_cdc_dcmd));
		ret = brcmf_bus_rxctl(drvr->bus_if, (unsigned char *)&prot->msg,
				      len);
		if (ret < 0)
			break;
	} while (CDC_DCMD_ID(le32_to_cpu(prot->msg.flags)) != id);
+4 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <brcmu_wifi.h>
#include <brcmu_utils.h>
#include "dhd.h"
#include "dhd_bus.h"
#include "dhd_dbg.h"

static struct dentry *root_folder;
@@ -42,10 +43,12 @@ void brcmf_debugfs_exit(void)

int brcmf_debugfs_attach(struct brcmf_pub *drvr)
{
	struct device *dev = drvr->bus_if->dev;

	if (!root_folder)
		return -ENODEV;

	drvr->dbgfs_dir = debugfs_create_dir(dev_name(drvr->dev), root_folder);
	drvr->dbgfs_dir = debugfs_create_dir(dev_name(dev), root_folder);
	return PTR_RET(drvr->dbgfs_dir);
}

+5 −6
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ static int brcmf_netdev_start_xmit(struct sk_buff *skb, struct net_device *ndev)
	brcmf_proto_hdrpush(drvr, ifp->idx, skb);

	/* Use bus module to send data frame */
	ret =  drvr->bus_if->brcmf_bus_txdata(drvr->dev, skb);
	ret =  brcmf_bus_txdata(drvr->bus_if, skb);

done:
	if (ret)
@@ -397,7 +397,7 @@ static void brcmf_ethtool_get_drvinfo(struct net_device *ndev,

	sprintf(info->driver, KBUILD_MODNAME);
	sprintf(info->version, "%lu", drvr->drv_version);
	sprintf(info->bus_info, "%s", dev_name(drvr->dev));
	sprintf(info->bus_info, "%s", dev_name(drvr->bus_if->dev));
}

static const struct ethtool_ops brcmf_ethtool_ops = {
@@ -753,7 +753,6 @@ int brcmf_attach(uint bus_hdrlen, struct device *dev)
	drvr->hdrlen = bus_hdrlen;
	drvr->bus_if = dev_get_drvdata(dev);
	drvr->bus_if->drvr = drvr;
	drvr->dev = dev;

	/* create device debugfs folder */
	brcmf_debugfs_attach(drvr);
@@ -790,7 +789,7 @@ int brcmf_bus_start(struct device *dev)
	brcmf_dbg(TRACE, "\n");

	/* Bring up the bus */
	ret = bus_if->brcmf_bus_init(dev);
	ret = brcmf_bus_init(bus_if);
	if (ret != 0) {
		brcmf_dbg(ERROR, "brcmf_sdbrcm_bus_init failed %d\n", ret);
		return ret;
@@ -809,7 +808,7 @@ int brcmf_bus_start(struct device *dev)
	if (ret < 0)
		goto fail;

	drvr->config = brcmf_cfg80211_attach(drvr);
	drvr->config = brcmf_cfg80211_attach(drvr, bus_if->dev);
	if (drvr->config == NULL) {
		ret = -ENOMEM;
		goto fail;
@@ -842,7 +841,7 @@ static void brcmf_bus_detach(struct brcmf_pub *drvr)
		brcmf_proto_stop(drvr);

		/* Stop the bus module */
		drvr->bus_if->brcmf_bus_stop(drvr->dev);
		brcmf_bus_stop(drvr->bus_if);
	}
}

Loading