| 1 |
/* SPDX-License-Identifier: ISC */ |
| 2 |
/* |
| 3 |
* Copyright (c) 2022 Broadcom Corporation |
| 4 |
*/ |
| 5 |
#ifndef FWVID_H_ |
| 6 |
#define FWVID_H_ |
| 7 |
|
| 8 |
#include "firmware.h" |
| 9 |
#include "cfg80211.h" |
| 10 |
|
| 11 |
struct brcmf_pub; |
| 12 |
struct brcmf_if; |
| 13 |
|
| 14 |
struct brcmf_fwvid_ops { |
| 15 |
void (*feat_attach)(struct brcmf_if *ifp); |
| 16 |
int (*set_sae_password)(struct brcmf_if *ifp, struct cfg80211_crypto_settings *crypto); |
| 17 |
int (*alloc_fweh_info)(struct brcmf_pub *drvr); |
| 18 |
int (*activate_events)(struct brcmf_if *ifp); |
| 19 |
void (*get_cfg80211_ops)(struct brcmf_pub *drvr); |
| 20 |
void (*register_event_handlers)(struct brcmf_pub *drvr); |
| 21 |
}; |
| 22 |
|
| 23 |
/* exported functions */ |
| 24 |
int brcmf_fwvid_register_vendor(enum brcmf_fwvendor fwvid, struct module *mod, |
| 25 |
const struct brcmf_fwvid_ops *ops); |
| 26 |
int brcmf_fwvid_unregister_vendor(enum brcmf_fwvendor fwvid, struct module *mod); |
| 27 |
|
| 28 |
/* core driver functions */ |
| 29 |
int brcmf_fwvid_attach(struct brcmf_pub *drvr); |
| 30 |
void brcmf_fwvid_detach(struct brcmf_pub *drvr); |
| 31 |
const char *brcmf_fwvid_vendor_name(struct brcmf_pub *drvr); |
| 32 |
|
| 33 |
static inline void brcmf_fwvid_feat_attach(struct brcmf_if *ifp) |
| 34 |
{ |
| 35 |
const struct brcmf_fwvid_ops *vops = ifp->drvr->vops; |
| 36 |
|
| 37 |
if (!vops->feat_attach) |
| 38 |
return; |
| 39 |
|
| 40 |
vops->feat_attach(ifp); |
| 41 |
} |
| 42 |
|
| 43 |
static inline int brcmf_fwvid_set_sae_password(struct brcmf_if *ifp, |
| 44 |
struct cfg80211_crypto_settings *crypto) |
| 45 |
{ |
| 46 |
const struct brcmf_fwvid_ops *vops = ifp->drvr->vops; |
| 47 |
|
| 48 |
if (!vops || !vops->set_sae_password) |
| 49 |
return -EOPNOTSUPP; |
| 50 |
|
| 51 |
return vops->set_sae_password(ifp, crypto); |
| 52 |
} |
| 53 |
|
| 54 |
static inline int brcmf_fwvid_alloc_fweh_info(struct brcmf_pub *drvr) |
| 55 |
{ |
| 56 |
if (!drvr->vops) |
| 57 |
return -EIO; |
| 58 |
|
| 59 |
return drvr->vops->alloc_fweh_info(drvr); |
| 60 |
} |
| 61 |
|
| 62 |
static inline int brcmf_fwvid_activate_events(struct brcmf_if *ifp) |
| 63 |
{ |
| 64 |
const struct brcmf_fwvid_ops *vops = ifp->drvr->vops; |
| 65 |
|
| 66 |
if (!vops || !vops->activate_events) |
| 67 |
return -EOPNOTSUPP; |
| 68 |
|
| 69 |
return vops->activate_events(ifp); |
| 70 |
} |
| 71 |
|
| 72 |
static inline void brcmf_fwvid_get_cfg80211_ops(struct brcmf_pub *drvr) |
| 73 |
{ |
| 74 |
if (!drvr->vops || !drvr->vops->get_cfg80211_ops) |
| 75 |
return; |
| 76 |
|
| 77 |
drvr->vops->get_cfg80211_ops(drvr); |
| 78 |
} |
| 79 |
|
| 80 |
static inline void brcmf_fwvid_register_event_handlers(struct brcmf_pub *drvr) |
| 81 |
{ |
| 82 |
if (!drvr->vops || !drvr->vops->register_event_handlers) |
| 83 |
return; |
| 84 |
|
| 85 |
drvr->vops->register_event_handlers(drvr); |
| 86 |
} |
| 87 |
|
| 88 |
#endif /* FWVID_H_ */ |