linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: suraj <suraj@atheros.com>
Cc: linux-bluetooth@vger.kernel.org, Luis.Rodriguez@Atheros.com,
	Jothikumar.Mothilal@Atheros.com, gfpadovan@gmail.com
Subject: Re: [PATCH v5] Add support for the Atheros AR300x Bluetooth Chip
Date: Thu, 20 May 2010 18:09:11 +0200	[thread overview]
Message-ID: <1274371751.27220.21.camel@localhost.localdomain> (raw)
In-Reply-To: <1271927414.1409.3.camel@atheros013-desktop>

Hi Suraj,

for every new patch version, please start a new thread. If you re-use an
old thread, I will most likely ignore it.

> +static struct sk_buff *ath_dequeue(struct hci_uart *hu)
> +{
> +	struct ath_struct *ath = hu->priv;
> +	struct sk_buff *skbuf;
> +
> +	skbuf = skb_dequeue(&ath->txq);
> +
> +	if (!skbuf)
> +		return NULL;
> +
> +	/*
> +	 * Check if the HCI command is  HCI sleep enable and
> +	 * update the sleep enable flag with command parameter.
> +	 *
> +	 * Value of sleep enable flag will be used later
> +	 * to verify if controller has to be woken up before
> +	 * sending any packet.
> +	 */
> +	if (skbuf->data[0] == 0x01 &&
> +	    skbuf->data[1] == 0x04 &&
> +	    skbuf->data[2] == 0xFC)
> +		ath->cur_sleep = skbuf->data[4];
> +
> +	return skbuf;
> +}

I don't really like this. I know we don't have any infrastructure to
forward vendor commands back to the driver. And we might need to change
that actually.

However at least for now use the headers and constants and not magic
numbers here.

> +static void ath_check_data_len(struct ath_struct *ath, int len)
> +{
> +	int room = skb_tailroom(ath->rx_skb);
> +
> +	BT_DBG("len %d room %d", len, room);
> +
> +	if (len > room) {
> +		BT_ERR("Data length is too large");
> +		kfree_skb(ath->rx_skb);
> +		ath->rx_state = HCIATH_W4_PACKET_TYPE;
> +		ath->rx_skb = NULL;
> +		ath->rx_count = 0;
> +	} else {
> +		ath->rx_state = HCIATH_W4_DATA;
> +		ath->rx_count = len;
> +	}
> +}
> +
> +/* Recv data */
> +static int ath_recv(struct hci_uart *hu, void *data, int count)
> +{
> +	struct ath_struct *ath = hu->priv;
> +	char *ptr = data;
> +	struct hci_event_hdr *eh;
> +	struct hci_acl_hdr *ah;
> +	struct hci_sco_hdr *sh;
> +	int len, type, dlen;
> +
> +	BT_DBG("hu %p count %d rx_state %d rx_count %d", hu, count,
> +	       ath->rx_state, ath->rx_count);
> +
> +	while (count) {
> +		if (ath->rx_count) {
> +
> +			len = min_t(unsigned int, ath->rx_count, count);
> +			memcpy(skb_put(ath->rx_skb, len), ptr, len);
> +			ath->rx_count -= len;
> +			count -= len;
> +			ptr += len;
> +
> +			if (ath->rx_count)
> +				continue;
> +			switch (ath->rx_state) {
> +			case HCIATH_W4_DATA:
> +				hci_recv_frame(ath->rx_skb);
> +				ath->rx_state = HCIATH_W4_PACKET_TYPE;
> +				ath->rx_skb = NULL;
> +				ath->rx_count = 0;
> +				continue;
> +
> +			case HCIATH_W4_EVENT_HDR:
> +				eh = hci_event_hdr(ath->rx_skb);
> +
> +				BT_DBG("Event header: evt 0x%2.2x plen %d",
> +				       eh->evt, eh->plen);
> +
> +				ath_check_data_len(ath, eh->plen);
> +				continue;
> +
> +			case HCIATH_W4_ACL_HDR:
> +				ah = hci_acl_hdr(ath->rx_skb);
> +				dlen = __le16_to_cpu(ah->dlen);
> +
> +				BT_DBG("ACL header: dlen %d", dlen);
> +
> +				ath_check_data_len(ath, dlen);
> +				continue;
> +
> +			case HCIATH_W4_SCO_HDR:
> +				sh = hci_sco_hdr(ath->rx_skb);
> +
> +				BT_DBG("SCO header: dlen %d", sh->dlen);
> +
> +				ath_check_data_len(ath, sh->dlen);
> +				continue;
> +
> +			}
> +		}
> +
> +		/* HCIATH_W4_PACKET_TYPE */
> +		switch (*ptr) {
> +		case HCI_EVENT_PKT:
> +			BT_DBG("Event packet");
> +			ath->rx_state = HCIATH_W4_EVENT_HDR;
> +			ath->rx_count = HCI_EVENT_HDR_SIZE;
> +			type = HCI_EVENT_PKT;
> +			break;
> +
> +		case HCI_ACLDATA_PKT:
> +			BT_DBG("ACL packet");
> +			ath->rx_state = HCIATH_W4_ACL_HDR;
> +			ath->rx_count = HCI_ACL_HDR_SIZE;
> +			type = HCI_ACLDATA_PKT;
> +			break;
> +
> +		case HCI_SCODATA_PKT:
> +			BT_DBG("SCO packet");
> +			ath->rx_state = HCIATH_W4_SCO_HDR;
> +			ath->rx_count = HCI_SCO_HDR_SIZE;
> +			type = HCI_SCODATA_PKT;
> +			break;
> +
> +		default:
> +			BT_ERR("Unknown HCI packet type %2.2x", (__u8) *ptr);
> +			hu->hdev->stat.err_rx++;
> +			ptr++;
> +			count--;
> +			continue;
> +
> +		};
> +		ptr++;
> +		count--;
> +
> +		/* Allocate packet */
> +		ath->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC);
> +		if (!ath->rx_skb) {
> +			BT_ERR("Can't allocate mem for new packet");
> +			ath->rx_state = HCIATH_W4_PACKET_TYPE;
> +			ath->rx_count = 0;
> +
> +			return -ENOMEM;
> +		}
> +		ath->rx_skb->dev = (void *)hu->hdev;
> +		bt_cb(ath->rx_skb)->pkt_type = type;
> +	}
> +
> +	return count;
> +}

What was the reason that hci_recv_fragment is not good enough here and
can not made work for this case. I really wanna avoid have multiple
implementation of this reassembly support all over the places.

Regards

Marcel



      parent reply	other threads:[~2010-05-20 16:09 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-15  5:01 [PATCH] Added support for Atheros AR300x Bluetooth Chip suraj
2010-03-24  5:27 ` suraj
2010-03-29  9:01   ` suraj
     [not found]     ` <1271673889.19858.4.camel@atheros013-desktop>
2010-04-19 18:11       ` Support " Luis R. Rodriguez
2010-03-31 10:59   ` [PATCH] Added Host level support for Atheros AR3xxx " suraj
2010-04-19 23:53 ` [PATCH] Added support for Atheros AR300x " Gustavo F. Padovan
2010-04-20 10:20 ` [PATCH v3] " suraj
2010-04-20 15:36   ` Gustavo F. Padovan
2010-04-20 17:34   ` Luis R. Rodriguez
2010-04-21  4:21     ` Suraj Sumangala
2010-04-21 10:22   ` [PATCH v4] Add support for the " suraj
2010-04-21 17:30     ` Luis R. Rodriguez
2010-04-22  6:10     ` Gustavo F. Padovan
2010-04-22  6:54       ` Suraj Sumangala
2010-04-22  8:59         ` Gustavo F. Padovan
2010-04-22  9:10     ` [PATCH v5] " suraj
2010-04-26 11:00       ` suraj
2010-04-27  6:19         ` [PATCH] New Firmware for Atheros bluetooth chipset AR3011 suraj
2010-04-27  8:28           ` [PATCH] patch to request new firmware for AR3011 Chip suraj
2010-04-27 15:55             ` Luis R. Rodriguez
2010-05-11  9:04             ` [PATCH v2] ath3k: add support for new firmware suraj
2010-05-05 12:33         ` [PATCH v5] Add support for the Atheros AR300x Bluetooth Chip suraj
2010-05-06  7:45           ` buffer starvation with multiple ACL link suraj
2010-05-20 16:02             ` Marcel Holtmann
2010-05-10 20:12           ` [PATCH v5] Add support for the Atheros AR300x Bluetooth Chip Luis R. Rodriguez
2010-05-11  8:29           ` suraj
2010-05-18 11:39             ` suraj
2010-05-12 13:47       ` [PATCH v3] hciattach application support for " suraj
2010-05-20 13:37         ` suraj
2010-05-20 16:00         ` Marcel Holtmann
2010-05-21  5:01           ` Suraj Sumangala
2010-05-21  7:34             ` Marcel Holtmann
2010-05-20 16:09       ` Marcel Holtmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1274371751.27220.21.camel@localhost.localdomain \
    --to=marcel@holtmann.org \
    --cc=Jothikumar.Mothilal@Atheros.com \
    --cc=Luis.Rodriguez@Atheros.com \
    --cc=gfpadovan@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=suraj@atheros.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).