From patchwork Thu Oct 11 20:01:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pontus Fuchs X-Patchwork-Id: 1583951 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 68596DFABE for ; Thu, 11 Oct 2012 20:02:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755249Ab2JKUCH (ORCPT ); Thu, 11 Oct 2012 16:02:07 -0400 Received: from mail-lb0-f174.google.com ([209.85.217.174]:42582 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753395Ab2JKUCC (ORCPT ); Thu, 11 Oct 2012 16:02:02 -0400 Received: by mail-lb0-f174.google.com with SMTP id n3so1584839lbo.19 for ; Thu, 11 Oct 2012 13:02:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=TtA9sk3rUxa5P7zP9kOU+pFmReIrX15z5D4sjOvsJcE=; b=e+ed85T8Zm85M85JCaYIDkzGJUwGoQY5zl1A0b0V+hZvm0blHpuDBcUyb5Rco680d+ 04lsrFwR0cWdDg4FDRrX8+Vqq+ANnKylmkGrVIhlojjriZj48qHZ76UrtuThZmss9hGg 5YXkZ8TQABUKNimkLrtf3iHd81kWkpf9/+MIuwgmAfhsT2TFP9A7997mXqX+Y8XUCtKx R2fOGx/neDMxPF95QhYa03fEYJGp5ZaIfeWpN7D8SAv+SNka19fXmJkLBKYUXKeB4n5L 7qa3+PhY3HrE9pAhgQAMN+EIQ7PfIxu5MOyJkEX37+G0gwUJOPmPDtQcpJc1lKtuynhd vGig== Received: by 10.152.103.38 with SMTP id ft6mr1818852lab.40.1349985721916; Thu, 11 Oct 2012 13:02:01 -0700 (PDT) Received: from localhost.localdomain (h209n4-m-sp-d1.ias.bredband.telia.com. [78.70.41.209]) by mx.google.com with ESMTPS id pz9sm1634393lab.11.2012.10.11.13.02.00 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 11 Oct 2012 13:02:01 -0700 (PDT) From: Pontus Fuchs To: gregkh@linuxfoundation.org Cc: linux-wireless@vger.kernel.org, hch@lst.de, s.L-H@gmx.de, Pontus Fuchs Subject: [PATCH 2/4] ar5523: Add driver header file Date: Thu, 11 Oct 2012 22:01:40 +0200 Message-Id: <1349985702-21322-3-git-send-email-pontus.fuchs@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1349985702-21322-1-git-send-email-pontus.fuchs@gmail.com> References: <1349985702-21322-1-git-send-email-pontus.fuchs@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Header file containing structures and defines used by the ar5523 driver. Signed-off-by: Pontus Fuchs --- drivers/staging/ar5523/ar5523.h | 164 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 drivers/staging/ar5523/ar5523.h diff --git a/drivers/staging/ar5523/ar5523.h b/drivers/staging/ar5523/ar5523.h new file mode 100644 index 0000000..119f9ed --- /dev/null +++ b/drivers/staging/ar5523/ar5523.h @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2012 Pontus Fuchs + * + * This file is free software: you may copy, redistribute and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 2 of the License, or (at your + * option) any later version. + * + * This file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright (c) 2006 + * Damien Bergamini + * Copyright (c) 2006 Sam Leffler, Errno Consulting + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#define AR5523_FLAG_PRE_FIRMWARE (1 << 0) +#define AR5523_FLAG_ABG (1 << 1) + +#define AR5523_FIRMWARE_FILE "ar5523.bin" + +#define AR5523_CMD_TX_PIPE 0x01 +#define AR5523_DATA_TX_PIPE 0x02 +#define AR5523_CMD_RX_PIPE 0x81 +#define AR5523_DATA_RX_PIPE 0x82 + +#define ar5523_cmd_tx_pipe(dev) \ + usb_sndbulkpipe((dev), AR5523_CMD_TX_PIPE) +#define ar5523_data_tx_pipe(dev) \ + usb_sndbulkpipe((dev), AR5523_DATA_TX_PIPE) +#define ar5523_cmd_rx_pipe(dev) \ + usb_rcvbulkpipe((dev), AR5523_CMD_RX_PIPE) +#define ar5523_data_rx_pipe(dev) \ + usb_rcvbulkpipe((dev), AR5523_DATA_RX_PIPE) + +#define AR5523_DATA_TIMEOUT 10000 +#define AR5523_CMD_TIMEOUT 1000 + +#define AR5523_TX_DATA_COUNT 4 +#define AR5523_TX_DATA_RESTART_COUNT 1 +#define AR5523_RX_DATA_COUNT 16 +#define AR5523_RX_DATA_REFILL_COUNT 8 + +#define AR5523_CMD_ID 1 +#define AR5523_DATA_ID 2 + +#define AR5523_TX_WD_TIMEOUT (HZ * 2) +#define AR5523_FLUSH_TIMEOUT (HZ * 3) + +enum AR5523_flags { + AR5523_HW_UP, + AR5523_USB_DISCONNECTED, + AR5523_CONNECTED +}; + +struct ar5523_tx_cmd { + struct ar5523 *ar; + struct urb *urb_tx; + void *buf_tx; + void *odata; + int olen; + int flags; + int res; + struct completion done; +}; + +/* This struct is placed in tx_info->driver_data. It must not be larger + * than IEEE80211_TX_INFO_DRIVER_DATA_SIZE. + */ +struct ar5523_tx_data { + struct list_head list; + struct ar5523 *ar; + struct sk_buff *skb; + struct urb *urb; +}; + +struct ar5523_rx_data { + struct list_head list; + struct ar5523 *ar; + struct urb *urb; + struct sk_buff *skb; +}; + +struct ar5523 { + struct usb_device *dev; + struct ieee80211_hw *hw; + + unsigned long flags; + struct mutex mutex; + struct workqueue_struct *wq; + + struct ar5523_tx_cmd tx_cmd; + + struct delayed_work stat_work; + + struct timer_list tx_wd_timer; + struct work_struct tx_wd_work; + struct work_struct tx_work; + struct list_head tx_queue_pending; + struct list_head tx_queue_submitted; + spinlock_t tx_data_list_lock; + wait_queue_head_t tx_flush_waitq; + + /* Queued + Submitted TX frames */ + atomic_t tx_nr_total; + + /* Submitted TX frames */ + atomic_t tx_nr_pending; + + void *rx_cmd_buf; + struct urb *rx_cmd_urb; + + struct ar5523_rx_data rx_data[AR5523_RX_DATA_COUNT]; + spinlock_t rx_data_list_lock; + struct list_head rx_data_free; + struct list_head rx_data_used; + atomic_t rx_data_free_cnt; + + struct work_struct rx_refill_work; + + int rxbufsz; + u8 serial[16]; + + struct ieee80211_channel channels[14]; + struct ieee80211_rate rates[12]; + struct ieee80211_supported_band band; + struct ieee80211_vif *vif; +}; + +/* flags for sending firmware commands */ +#define AR5523_CMD_FLAG_READ (1 << 1) +#define AR5523_CMD_FLAG_MAGIC (1 << 2) + +#define ar5523_dbg(ar, format, arg...) \ + dev_dbg(&(ar)->dev->dev, format, ## arg) +#define ar5523_err(ar, format, arg...) \ +do { \ + if (!test_bit(AR5523_USB_DISCONNECTED, &ar->flags)) { \ + dev_err(&(ar)->dev->dev, format, ## arg); \ + } \ +} while (0) +#define ar5523_info(ar, format, arg...) \ + dev_info(&(ar)->dev->dev, format, ## arg) +