From patchwork Thu Nov 15 02:46:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Franky Lin X-Patchwork-Id: 1745201 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 8883A3FCF7 for ; Thu, 15 Nov 2012 02:47:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933258Ab2KOCrA (ORCPT ); Wed, 14 Nov 2012 21:47:00 -0500 Received: from mms1.broadcom.com ([216.31.210.17]:3245 "EHLO mms1.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933227Ab2KOCqc (ORCPT ); Wed, 14 Nov 2012 21:46:32 -0500 Received: from [10.9.200.133] by mms1.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.5)); Wed, 14 Nov 2012 18:44:38 -0800 X-Server-Uuid: 06151B78-6688-425E-9DE2-57CB27892261 Received: from mail-irva-13.broadcom.com (10.11.16.103) by IRVEXCHHUB02.corp.ad.broadcom.com (10.9.200.133) with Microsoft SMTP Server id 8.2.247.2; Wed, 14 Nov 2012 18:46:01 -0800 Received: from mail-sj1-12.sj.broadcom.com (mail-sj1-12.sj.broadcom.com [10.17.16.106]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 63B1140FE4; Wed, 14 Nov 2012 18:46:27 -0800 (PST) Received: from lc-sj1-3560.broadcom.com (lc-sj1-3560.sj.broadcom.com [10.17.194.250]) by mail-sj1-12.sj.broadcom.com (Postfix) with ESMTP id DAECF207DE; Wed, 14 Nov 2012 18:46:24 -0800 (PST) Received: by lc-sj1-3560.broadcom.com (Postfix, from userid 25250) id A462DF88E52; Wed, 14 Nov 2012 18:46:23 -0800 (PST) From: "Franky Lin" To: linville@tuxdriver.com cc: linux-wireless@vger.kernel.org, "Arend van Spriel" Subject: [PATCH 12/19] brcmfmac: restructure handling of IF event Date: Wed, 14 Nov 2012 18:46:16 -0800 Message-ID: <1352947583-25341-13-git-send-email-frankyl@broadcom.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1352947583-25341-1-git-send-email-frankyl@broadcom.com> References: <1352947583-25341-1-git-send-email-frankyl@broadcom.com> MIME-Version: 1.0 X-WSS-ID: 7CBA889C1QK2801632-02-01 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Arend van Spriel The IF event need special care. It can be either an ADD, DEL, or CHANGE. For an ADD we need to call brcmf_add_if() before the event handler call. Upon a DEL we need to call brcmf_del_if() after the event handler call. CHANGE does not require special attention. Reviewed-by: Hante Meuleman Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin --- drivers/net/wireless/brcm80211/brcmfmac/fweh.c | 102 +++++++++++++----------- 1 file changed, 55 insertions(+), 47 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/fweh.c b/drivers/net/wireless/brcm80211/brcmfmac/fweh.c index 7b57b89..37f853d 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/fweh.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/fweh.c @@ -205,19 +205,40 @@ static void brcmf_fweh_queue_event(struct brcmf_fweh_info *fweh, schedule_work(&fweh->event_work); } +static int brcmf_fweh_call_event_handler(struct brcmf_if *ifp, + enum brcmf_fweh_event_code code, + struct brcmf_event_msg *emsg, + void *data) +{ + struct brcmf_fweh_info *fweh; + int err = -EINVAL; + + if (ifp) { + fweh = &ifp->drvr->fweh; + + /* handle the event if valid interface and handler */ + if (ifp->ndev && fweh->evt_handler[code]) + err = fweh->evt_handler[code](ifp, emsg, data); + else + brcmf_dbg(ERROR, "unhandled event %d ignored\n", code); + } else { + brcmf_dbg(ERROR, "no interface object\n"); + } + return err; +} + /** - * brcmf_fweh_process_if_event() - handle IF event. + * brcmf_fweh_handle_if_event() - handle IF event. * * @drvr: driver information object. * @item: queue entry. * @ifpp: interface object (may change upon ADD action). */ -static int brcmf_fweh_process_if_event(struct brcmf_pub *drvr, - struct brcmf_fweh_queue_item *item, - struct brcmf_if **ifpp) +static void brcmf_fweh_handle_if_event(struct brcmf_pub *drvr, + struct brcmf_event_msg *emsg, + void *data) { - struct brcmf_event_msg_be *event = &item->emsg; - struct brcmf_if_event *ifevent = (struct brcmf_if_event *)item->data; + struct brcmf_if_event *ifevent = data; struct brcmf_if *ifp; int err = 0; @@ -228,34 +249,27 @@ static int brcmf_fweh_process_if_event(struct brcmf_pub *drvr, if (ifevent->ifidx >= BRCMF_MAX_IFS) { brcmf_dbg(ERROR, "invalid interface index: %u\n", ifevent->ifidx); - return -EINVAL; + return; } - switch (ifevent->action) { - case BRCMF_E_IF_ADD: - brcmf_dbg(EVENT, "adding %s (%pM, %pM)\n", event->ifname, - event->addr, item->ifaddr); + ifp = drvr->iflist[ifevent->ifidx]; + + if (ifevent->action == BRCMF_E_IF_ADD) { + brcmf_dbg(EVENT, "adding %s (%pM)\n", emsg->ifname, + emsg->addr); ifp = brcmf_add_if(drvr, ifevent->ifidx, ifevent->bssidx, - event->ifname, item->ifaddr); - if (!IS_ERR(ifp)) { - *ifpp = ifp; + emsg->ifname, emsg->addr); + if (IS_ERR(ifp)) + return; + + if (!drvr->fweh.evt_handler[BRCMF_E_IF]) err = brcmf_net_attach(ifp); - } else { - err = PTR_ERR(ifp); - } - break; - case BRCMF_E_IF_DEL: - brcmf_del_if(drvr, ifevent->ifidx); - break; - case BRCMF_E_IF_CHANGE: - /* nothing to do here */ - break; - default: - brcmf_dbg(ERROR, "unknown event action: %u\n", ifevent->action); - err = -EBADE; - break; } - return err; + + err = brcmf_fweh_call_event_handler(ifp, emsg->event_code, emsg, data); + + if (ifevent->action == BRCMF_E_IF_DEL) + brcmf_del_if(drvr, ifevent->ifidx); } /** @@ -306,13 +320,6 @@ static void brcmf_fweh_event_worker(struct work_struct *work) event->emsg.ifidx, event->emsg.bsscfgidx, event->emsg.addr); - /* handle interface event */ - if (event->code == BRCMF_E_IF) { - err = brcmf_fweh_process_if_event(drvr, event, &ifp); - if (err) - goto event_free; - } - /* convert event message */ emsg_be = &event->emsg; emsg.version = be16_to_cpu(emsg_be->version); @@ -333,13 +340,14 @@ static void brcmf_fweh_event_worker(struct work_struct *work) min_t(u32, emsg.datalen, 64), "appended:"); - /* handle the event if valid interface and handler */ - if (ifp->ndev && fweh->evt_handler[event->code]) - err = fweh->evt_handler[event->code](ifp, &emsg, - event->data); - else - brcmf_dbg(ERROR, "unhandled event %d ignored\n", - event->code); + /* special handling of interface event */ + if (event->code == BRCMF_E_IF) { + brcmf_fweh_handle_if_event(drvr, &emsg, event->data); + goto event_free; + } + + err = brcmf_fweh_call_event_handler(ifp, event->code, &emsg, + event->data); if (err) { brcmf_dbg(ERROR, "event handler failed (%d)\n", event->code); @@ -477,11 +485,11 @@ void brcmf_fweh_process_event(struct brcmf_pub *drvr, *ifidx = event_packet->msg.ifidx; data = &event_packet[1]; - if (code != BRCMF_E_IF && !fweh->evt_handler[code]) { - brcmf_dbg(EVENT, "event ignored: code=%d\n", code); - brcmf_dbg_hex_dump(BRCMF_EVENT_ON(), data, datalen, "event:"); + if (code >= BRCMF_E_LAST) + return; + + if (code != BRCMF_E_IF && !fweh->evt_handler[code]) return; - } if (in_interrupt()) alloc_flag = GFP_ATOMIC;