From patchwork Thu Oct 13 16:39:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Stromdahl X-Patchwork-Id: 9375443 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5D59560487 for ; Thu, 13 Oct 2016 16:42:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CE9E2A16B for ; Thu, 13 Oct 2016 16:42:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 417382A16E; Thu, 13 Oct 2016 16:42:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69C8B2A16B for ; Thu, 13 Oct 2016 16:41:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933194AbcJMQl6 (ORCPT ); Thu, 13 Oct 2016 12:41:58 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:34376 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933191AbcJMQlu (ORCPT ); Thu, 13 Oct 2016 12:41:50 -0400 Received: by mail-lf0-f65.google.com with SMTP id x23so7787470lfi.1 for ; Thu, 13 Oct 2016 09:41:31 -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:in-reply-to:references; bh=4gGhRUpUFdlIdKkn/aeICI9eERCDnnFHfniXyov2tbU=; b=n5e3c4MbaHHTNdLvdYOf7wBDhvk3CaRPuSnpdDmM4PiDSoUnEUGbXskvWkRNgui67q kdYzOlKARhX93cyCPC7QFauSmznzgg7mcb3aIK4TkOiNpNUjdD5jKidSzIRIyc3xdVbf bx00AFZwJ/a2ehsaTI5OTq1XIkUqSyna1ciHy0z+Q/YGkcMeMxs5WHlDWRTNjtnPu7PN wMM+erBGVna1yiU/oJOvRiC5va5L0POuGSHzci1RvAhVp3hL5IyuaSf2ZN+MPsvVGpcx voPbEBwx3naqglW0f92elciW0UXF8OO2I+DhNRezpqwbs+6/e7nptGj1NYNoJxfmH0H9 onYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4gGhRUpUFdlIdKkn/aeICI9eERCDnnFHfniXyov2tbU=; b=SxvLJF5XYCbFWO3am5V0qWlJDYEWwmu5YeeDFFyQHfr+hkERYmW/CcLgNQOqzhZEx9 UZjOsUixDRNCcY53r2YATfHCqJ4Q4rK7ldf9xkyQ8F9bQHPxC8GaLpcxKJojA12Ry5qw dFp5/EsWM0DzWmTDgTRzLKZIqLvyA8BX6IIH2U1+XL6mbkdne6elDr9EqYm+Pp+3o72Y xf8RCXIiZrgiHsYbG7EfBOvVFS83HzFjtEgVvye1oOEfopwyaoP/tQ026Pvu1PQvOnMz pXg95MXJCvIM4I/GaeQ8FibpSaW9zkLoN89/WS5NWP4yuTvAKmL6IWM8c5VWclsgQgJw N5CA== X-Gm-Message-State: AA6/9RmImCRgCF0yP3Xfc68mi0H+Z2SAFDZ4e0aQYQs0+DMJIu0je6Tqc3b5BJ5ruwqEUQ== X-Received: by 10.25.198.9 with SMTP id w9mr11388342lff.164.1476376890584; Thu, 13 Oct 2016 09:41:30 -0700 (PDT) Received: from erik-desktop.lan (81-233-218-8-no25.tbcn.telia.com. [81.233.218.8]) by smtp.gmail.com with ESMTPSA id j124sm3986330lfe.3.2016.10.13.09.41.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Oct 2016 09:41:30 -0700 (PDT) From: Erik Stromdahl To: kvalo@qca.qualcomm.com, linux-wireless@vger.kernel.org Cc: Erik Stromdahl Subject: [RFC 5/5] ath6kl: service connect rewrite Date: Thu, 13 Oct 2016 18:39:29 +0200 Message-Id: <1476376769-4708-6-git-send-email-erik.stromdahl@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1476376769-4708-1-git-send-email-erik.stromdahl@gmail.com> References: <1476376769-4708-1-git-send-email-erik.stromdahl@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch removes the hardcoded struct htc_service_connect_req from ath6kl_init_service_ep and adds an array of struct htc_service_connect_req's to each element in hw_list. The rationale behind this patch is to make it possible to select which services to connect to depending on chipset. Signed-off-by: Erik Stromdahl --- drivers/net/wireless/ath/ath6kl/core.h | 3 + drivers/net/wireless/ath/ath6kl/htc-ops.h | 2 +- drivers/net/wireless/ath/ath6kl/htc.h | 2 +- drivers/net/wireless/ath/ath6kl/htc_mbox.c | 2 +- drivers/net/wireless/ath/ath6kl/htc_pipe.c | 2 +- drivers/net/wireless/ath/ath6kl/init.c | 187 +++++++++++++++++------------ 6 files changed, 117 insertions(+), 81 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index ac25f17..f907ef4 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -799,6 +799,9 @@ struct ath6kl { const char *testscript; } fw; + const struct htc_service_connect_req *services; + u32 service_count; + const char *fw_board; const char *fw_default_board; } hw; diff --git a/drivers/net/wireless/ath/ath6kl/htc-ops.h b/drivers/net/wireless/ath/ath6kl/htc-ops.h index 2d4eed5..80700a4 100644 --- a/drivers/net/wireless/ath/ath6kl/htc-ops.h +++ b/drivers/net/wireless/ath/ath6kl/htc-ops.h @@ -36,7 +36,7 @@ static inline int ath6kl_htc_start(struct htc_target *target) } static inline int ath6kl_htc_conn_service(struct htc_target *target, - struct htc_service_connect_req *req, + const struct htc_service_connect_req *req, struct htc_service_connect_resp *resp) { return target->dev->ar->htc_ops->conn_service(target, req, resp); diff --git a/drivers/net/wireless/ath/ath6kl/htc.h b/drivers/net/wireless/ath/ath6kl/htc.h index 532b13b..bfff466 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.h +++ b/drivers/net/wireless/ath/ath6kl/htc.h @@ -550,7 +550,7 @@ struct ath6kl_htc_ops { int (*wait_target)(struct htc_target *target); int (*start)(struct htc_target *target); int (*conn_service)(struct htc_target *target, - struct htc_service_connect_req *req, + const struct htc_service_connect_req *req, struct htc_service_connect_resp *resp); int (*tx)(struct htc_target *target, struct htc_packet *packet); void (*stop)(struct htc_target *target); diff --git a/drivers/net/wireless/ath/ath6kl/htc_mbox.c b/drivers/net/wireless/ath/ath6kl/htc_mbox.c index eed3939..24fb9a7 100644 --- a/drivers/net/wireless/ath/ath6kl/htc_mbox.c +++ b/drivers/net/wireless/ath/ath6kl/htc_mbox.c @@ -2386,7 +2386,7 @@ static void ath6kl_htc_mbox_flush_rx_buf(struct htc_target *target) } static int ath6kl_htc_mbox_conn_service(struct htc_target *target, - struct htc_service_connect_req *conn_req, + const struct htc_service_connect_req *conn_req, struct htc_service_connect_resp *conn_resp) { struct htc_packet *rx_pkt = NULL; diff --git a/drivers/net/wireless/ath/ath6kl/htc_pipe.c b/drivers/net/wireless/ath/ath6kl/htc_pipe.c index 93aac63..9a39f3d 100644 --- a/drivers/net/wireless/ath/ath6kl/htc_pipe.c +++ b/drivers/net/wireless/ath/ath6kl/htc_pipe.c @@ -1226,7 +1226,7 @@ static u8 htc_get_credit_alloc(struct htc_target *target, u16 service_id) } static int ath6kl_htc_pipe_conn_service(struct htc_target *target, - struct htc_service_connect_req *conn_req, + const struct htc_service_connect_req *conn_req, struct htc_service_connect_resp *conn_resp) { struct ath6kl *ar = target->dev->ar; diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 58fb227..a4c7abe 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -32,6 +32,94 @@ #include "hif-ops.h" #include "htc-ops.h" +const struct htc_service_connect_req ar600x_services[] = { + { + .svc_id = WMI_CONTROL_SVC, + .ep_cb = { + .tx_comp_multi = ath6kl_tx_complete, + .rx = ath6kl_rx, + .rx_refill = ath6kl_rx_refill, + .tx_full = ath6kl_tx_queue_full, + .rx_refill_thresh = ATH6KL_MAX_RX_BUFFERS / 4, + }, + .max_txq_depth = MAX_DEFAULT_SEND_QUEUE_DEPTH, + }, + { + .svc_id = WMI_DATA_BE_SVC, + .conn_flags = HTC_CONN_FLGS_REDUCE_CRED_DRIB | + HTC_CONN_FLGS_THRESH_LVL_HALF, + .ep_cb = { + .tx_comp_multi = ath6kl_tx_complete, + .rx = ath6kl_rx, + .rx_refill = ath6kl_rx_refill, + .tx_full = ath6kl_tx_queue_full, + .rx_refill_thresh = ATH6KL_MAX_RX_BUFFERS / 4, + .rx_alloc_thresh = ATH6KL_BUFFER_SIZE, + .rx_allocthresh = ath6kl_alloc_amsdu_rxbuf, + }, + .max_txq_depth = MAX_DEFAULT_SEND_QUEUE_DEPTH, + .flags = HTC_FLGS_TX_BNDL_PAD_EN, + .max_rxmsg_sz = WMI_MAX_TX_DATA_FRAME_LENGTH, + }, + { + .svc_id = WMI_DATA_BK_SVC, + .conn_flags = HTC_CONN_FLGS_REDUCE_CRED_DRIB | + HTC_CONN_FLGS_THRESH_LVL_HALF, + .ep_cb = { + .tx_comp_multi = ath6kl_tx_complete, + .rx = ath6kl_rx, + .rx_refill = ath6kl_rx_refill, + .tx_full = ath6kl_tx_queue_full, + .rx_refill_thresh = ATH6KL_MAX_RX_BUFFERS / 4, + .rx_alloc_thresh = ATH6KL_BUFFER_SIZE, + .rx_allocthresh = ath6kl_alloc_amsdu_rxbuf, + }, + .max_txq_depth = MAX_DEFAULT_SEND_QUEUE_DEPTH, + .flags = HTC_FLGS_TX_BNDL_PAD_EN, + .max_rxmsg_sz = WMI_MAX_TX_DATA_FRAME_LENGTH, + }, + { + .svc_id = WMI_DATA_VI_SVC, + .conn_flags = HTC_CONN_FLGS_REDUCE_CRED_DRIB | + HTC_CONN_FLGS_THRESH_LVL_HALF, + .ep_cb = { + .tx_comp_multi = ath6kl_tx_complete, + .rx = ath6kl_rx, + .rx_refill = ath6kl_rx_refill, + .tx_full = ath6kl_tx_queue_full, + .rx_refill_thresh = ATH6KL_MAX_RX_BUFFERS / 4, + .rx_alloc_thresh = ATH6KL_BUFFER_SIZE, + .rx_allocthresh = ath6kl_alloc_amsdu_rxbuf, + }, + .max_txq_depth = MAX_DEFAULT_SEND_QUEUE_DEPTH, + .flags = HTC_FLGS_TX_BNDL_PAD_EN, + .max_rxmsg_sz = WMI_MAX_TX_DATA_FRAME_LENGTH, + }, + /* VO service, this is currently not mapped to a WMI + * priority stream due to historical reasons. WMI originally + * defined 3 priorities over 3 mailboxes We can change this when + * WMI is reworked so that priorities are not dependent on + * mailboxes. + */ + { + .svc_id = WMI_DATA_VO_SVC, + .conn_flags = HTC_CONN_FLGS_REDUCE_CRED_DRIB | + HTC_CONN_FLGS_THRESH_LVL_HALF, + .ep_cb = { + .tx_comp_multi = ath6kl_tx_complete, + .rx = ath6kl_rx, + .rx_refill = ath6kl_rx_refill, + .tx_full = ath6kl_tx_queue_full, + .rx_refill_thresh = ATH6KL_MAX_RX_BUFFERS / 4, + .rx_alloc_thresh = ATH6KL_BUFFER_SIZE, + .rx_allocthresh = ath6kl_alloc_amsdu_rxbuf, + }, + .max_txq_depth = MAX_DEFAULT_SEND_QUEUE_DEPTH, + .flags = HTC_FLGS_TX_BNDL_PAD_EN, + .max_rxmsg_sz = WMI_MAX_TX_DATA_FRAME_LENGTH, + }, +}; + static const struct ath6kl_hw hw_list[] = { { .id = AR6003_HW_2_0_VERSION, @@ -57,6 +145,8 @@ static const struct ath6kl_hw hw_list[] = { .fw_board = AR6003_HW_2_0_BOARD_DATA_FILE, .fw_default_board = AR6003_HW_2_0_DEFAULT_BOARD_DATA_FILE, + .services = ar600x_services, + .service_count = ARRAY_SIZE(ar600x_services), }, { .id = AR6003_HW_2_1_1_VERSION, @@ -82,6 +172,8 @@ static const struct ath6kl_hw hw_list[] = { .fw_board = AR6003_HW_2_1_1_BOARD_DATA_FILE, .fw_default_board = AR6003_HW_2_1_1_DEFAULT_BOARD_DATA_FILE, + .services = ar600x_services, + .service_count = ARRAY_SIZE(ar600x_services), }, { .id = AR6004_HW_1_0_VERSION, @@ -102,6 +194,8 @@ static const struct ath6kl_hw hw_list[] = { .fw_board = AR6004_HW_1_0_BOARD_DATA_FILE, .fw_default_board = AR6004_HW_1_0_DEFAULT_BOARD_DATA_FILE, + .services = ar600x_services, + .service_count = ARRAY_SIZE(ar600x_services), }, { .id = AR6004_HW_1_1_VERSION, @@ -121,6 +215,8 @@ static const struct ath6kl_hw hw_list[] = { .fw_board = AR6004_HW_1_1_BOARD_DATA_FILE, .fw_default_board = AR6004_HW_1_1_DEFAULT_BOARD_DATA_FILE, + .services = ar600x_services, + .service_count = ARRAY_SIZE(ar600x_services), }, { .id = AR6004_HW_1_2_VERSION, @@ -140,6 +236,8 @@ static const struct ath6kl_hw hw_list[] = { }, .fw_board = AR6004_HW_1_2_BOARD_DATA_FILE, .fw_default_board = AR6004_HW_1_2_DEFAULT_BOARD_DATA_FILE, + .services = ar600x_services, + .service_count = ARRAY_SIZE(ar600x_services), }, { .id = AR6004_HW_1_3_VERSION, @@ -163,6 +261,8 @@ static const struct ath6kl_hw hw_list[] = { .fw_board = AR6004_HW_1_3_BOARD_DATA_FILE, .fw_default_board = AR6004_HW_1_3_DEFAULT_BOARD_DATA_FILE, + .services = ar600x_services, + .service_count = ARRAY_SIZE(ar600x_services), }, { .id = AR6004_HW_3_0_VERSION, @@ -186,6 +286,8 @@ static const struct ath6kl_hw hw_list[] = { .fw_board = AR6004_HW_3_0_BOARD_DATA_FILE, .fw_default_board = AR6004_HW_3_0_DEFAULT_BOARD_DATA_FILE, + .services = ar600x_services, + .service_count = ARRAY_SIZE(ar600x_services), }, }; @@ -280,8 +382,7 @@ static inline void set_ac2_ep_map(struct ath6kl *ar, /* connect to a service */ static int ath6kl_connectservice(struct ath6kl *ar, - struct htc_service_connect_req *con_req, - char *desc) + const struct htc_service_connect_req *con_req) { int status; struct htc_service_connect_resp response; @@ -290,8 +391,8 @@ static int ath6kl_connectservice(struct ath6kl *ar, status = ath6kl_htc_conn_service(ar->htc_target, con_req, &response); if (status) { - ath6kl_err("failed to connect to %s service status:%d\n", - desc, status); + ath6kl_err("failed to connect to %x service status: %d\n", + con_req->svc_id, status); return status; } @@ -323,80 +424,12 @@ static int ath6kl_connectservice(struct ath6kl *ar, static int ath6kl_init_service_ep(struct ath6kl *ar) { - struct htc_service_connect_req connect; - - memset(&connect, 0, sizeof(connect)); - - /* these fields are the same for all service endpoints */ - connect.ep_cb.tx_comp_multi = ath6kl_tx_complete; - connect.ep_cb.rx = ath6kl_rx; - connect.ep_cb.rx_refill = ath6kl_rx_refill; - connect.ep_cb.tx_full = ath6kl_tx_queue_full; - - /* - * Set the max queue depth so that our ath6kl_tx_queue_full handler - * gets called. - */ - connect.max_txq_depth = MAX_DEFAULT_SEND_QUEUE_DEPTH; - connect.ep_cb.rx_refill_thresh = ATH6KL_MAX_RX_BUFFERS / 4; - if (!connect.ep_cb.rx_refill_thresh) - connect.ep_cb.rx_refill_thresh++; - - /* connect to control service */ - connect.svc_id = WMI_CONTROL_SVC; - if (ath6kl_connectservice(ar, &connect, "WMI CONTROL")) - return -EIO; - - connect.flags |= HTC_FLGS_TX_BNDL_PAD_EN; - - /* - * Limit the HTC message size on the send path, although e can - * receive A-MSDU frames of 4K, we will only send ethernet-sized - * (802.3) frames on the send path. - */ - connect.max_rxmsg_sz = WMI_MAX_TX_DATA_FRAME_LENGTH; - - /* - * To reduce the amount of committed memory for larger A_MSDU - * frames, use the recv-alloc threshold mechanism for larger - * packets. - */ - connect.ep_cb.rx_alloc_thresh = ATH6KL_BUFFER_SIZE; - connect.ep_cb.rx_allocthresh = ath6kl_alloc_amsdu_rxbuf; - - /* - * For the remaining data services set the connection flag to - * reduce dribbling, if configured to do so. - */ - connect.conn_flags |= HTC_CONN_FLGS_REDUCE_CRED_DRIB; - connect.conn_flags &= ~HTC_CONN_FLGS_THRESH_MASK; - connect.conn_flags |= HTC_CONN_FLGS_THRESH_LVL_HALF; - - connect.svc_id = WMI_DATA_BE_SVC; - - if (ath6kl_connectservice(ar, &connect, "WMI DATA BE")) - return -EIO; - - /* connect to back-ground map this to WMI LOW_PRI */ - connect.svc_id = WMI_DATA_BK_SVC; - if (ath6kl_connectservice(ar, &connect, "WMI DATA BK")) - return -EIO; - - /* connect to Video service, map this to HI PRI */ - connect.svc_id = WMI_DATA_VI_SVC; - if (ath6kl_connectservice(ar, &connect, "WMI DATA VI")) - return -EIO; + int i; - /* - * Connect to VO service, this is currently not mapped to a WMI - * priority stream due to historical reasons. WMI originally - * defined 3 priorities over 3 mailboxes We can change this when - * WMI is reworked so that priorities are not dependent on - * mailboxes. - */ - connect.svc_id = WMI_DATA_VO_SVC; - if (ath6kl_connectservice(ar, &connect, "WMI DATA VO")) - return -EIO; + for (i = 0; i < ar->hw.service_count; i++) { + if (ath6kl_connectservice(ar, &ar->hw.services[i])) + return -EIO; + } return 0; }