mka: Pass full structures down to macsec drivers' receive SA ops
Clean up the driver interface by passing pointers to struct receive_sa down the stack to the {create,enable,disable}_receive_sa() ops, instead of passing the individual properties of the SA. Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
This commit is contained in:
parent
909c1b9835
commit
cecdecdbe8
6 changed files with 44 additions and 47 deletions
|
@ -3391,32 +3391,26 @@ struct wpa_driver_ops {
|
||||||
/**
|
/**
|
||||||
* create_receive_sa - create secure association for receive
|
* create_receive_sa - create secure association for receive
|
||||||
* @priv: private driver interface data from init()
|
* @priv: private driver interface data from init()
|
||||||
* @channel: secure channel
|
* @sa: secure association
|
||||||
* @an: association number
|
|
||||||
* @lowest_pn: the lowest packet number can be received
|
|
||||||
* @sak: the secure association key
|
|
||||||
* Returns: 0 on success, -1 on failure
|
* Returns: 0 on success, -1 on failure
|
||||||
*/
|
*/
|
||||||
int (*create_receive_sa)(void *priv, u32 channel, u8 an,
|
int (*create_receive_sa)(void *priv, struct receive_sa *sa);
|
||||||
u32 lowest_pn, const u8 *sak);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* enable_receive_sa - enable the SA for receive
|
* enable_receive_sa - enable the SA for receive
|
||||||
* @priv: private driver interface data from init()
|
* @priv: private driver interface data from init()
|
||||||
* @channel: secure channel
|
* @sa: secure association
|
||||||
* @an: association number
|
|
||||||
* Returns: 0 on success, -1 on failure
|
* Returns: 0 on success, -1 on failure
|
||||||
*/
|
*/
|
||||||
int (*enable_receive_sa)(void *priv, u32 channel, u8 an);
|
int (*enable_receive_sa)(void *priv, struct receive_sa *sa);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* disable_receive_sa - disable SA for receive
|
* disable_receive_sa - disable SA for receive
|
||||||
* @priv: private driver interface data from init()
|
* @priv: private driver interface data from init()
|
||||||
* @channel: secure channel index
|
* @sa: secure association
|
||||||
* @an: association number
|
|
||||||
* Returns: 0 on success, -1 on failure
|
* Returns: 0 on success, -1 on failure
|
||||||
*/
|
*/
|
||||||
int (*disable_receive_sa)(void *priv, u32 channel, u8 an);
|
int (*disable_receive_sa)(void *priv, struct receive_sa *sa);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get_available_transmit_sc - get available transmit channel
|
* get_available_transmit_sc - get available transmit channel
|
||||||
|
|
|
@ -667,49 +667,57 @@ static int macsec_qca_delete_receive_sc(void *priv, u32 channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int macsec_qca_create_receive_sa(void *priv, u32 channel, u8 an,
|
static int macsec_qca_create_receive_sa(void *priv, struct receive_sa *sa)
|
||||||
u32 lowest_pn, const u8 *sak)
|
|
||||||
{
|
{
|
||||||
struct macsec_qca_data *drv = priv;
|
struct macsec_qca_data *drv = priv;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
fal_rx_sak_t rx_sak;
|
fal_rx_sak_t rx_sak;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
u32 channel = sa->sc->channel;
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "%s, channel=%d, an=%d, lpn=0x%x",
|
wpa_printf(MSG_DEBUG, "%s, channel=%d, an=%d, lpn=0x%x",
|
||||||
__func__, channel, an, lowest_pn);
|
__func__, channel, sa->an, sa->lowest_pn);
|
||||||
|
|
||||||
os_memset(&rx_sak, 0, sizeof(rx_sak));
|
os_memset(&rx_sak, 0, sizeof(rx_sak));
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
rx_sak.sak[i] = sak[15 - i];
|
rx_sak.sak[i] = sa->pkey->key[15 - i];
|
||||||
|
|
||||||
ret += nss_macsec_secy_rx_sa_create(drv->secy_id, channel, an);
|
ret += nss_macsec_secy_rx_sa_create(drv->secy_id, channel, sa->an);
|
||||||
ret += nss_macsec_secy_rx_sak_set(drv->secy_id, channel, an, &rx_sak);
|
ret += nss_macsec_secy_rx_sak_set(drv->secy_id, channel, sa->an,
|
||||||
|
&rx_sak);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int macsec_qca_enable_receive_sa(void *priv, u32 channel, u8 an)
|
static int macsec_qca_enable_receive_sa(void *priv, struct receive_sa *sa)
|
||||||
{
|
{
|
||||||
struct macsec_qca_data *drv = priv;
|
struct macsec_qca_data *drv = priv;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
u32 channel = sa->sc->channel;
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "%s: channel=%d, an=%d", __func__, channel, an);
|
|
||||||
|
|
||||||
ret += nss_macsec_secy_rx_sa_en_set(drv->secy_id, channel, an, TRUE);
|
wpa_printf(MSG_DEBUG, "%s: channel=%d, an=%d", __func__, channel,
|
||||||
|
sa->an);
|
||||||
|
|
||||||
|
ret += nss_macsec_secy_rx_sa_en_set(drv->secy_id, channel, sa->an,
|
||||||
|
TRUE);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int macsec_qca_disable_receive_sa(void *priv, u32 channel, u8 an)
|
static int macsec_qca_disable_receive_sa(void *priv, struct receive_sa *sa)
|
||||||
{
|
{
|
||||||
struct macsec_qca_data *drv = priv;
|
struct macsec_qca_data *drv = priv;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
u32 channel = sa->sc->channel;
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "%s: channel=%d, an=%d", __func__, channel, an);
|
wpa_printf(MSG_DEBUG, "%s: channel=%d, an=%d", __func__, channel,
|
||||||
|
sa->an);
|
||||||
|
|
||||||
ret += nss_macsec_secy_rx_sa_en_set(drv->secy_id, channel, an, FALSE);
|
ret += nss_macsec_secy_rx_sa_en_set(drv->secy_id, channel, sa->an,
|
||||||
|
FALSE);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,10 +151,9 @@ struct ieee802_1x_kay_ctx {
|
||||||
enum validate_frames vf,
|
enum validate_frames vf,
|
||||||
enum confidentiality_offset co);
|
enum confidentiality_offset co);
|
||||||
int (*delete_receive_sc)(void *ctx, u32 channel);
|
int (*delete_receive_sc)(void *ctx, u32 channel);
|
||||||
int (*create_receive_sa)(void *ctx, u32 channel, u8 an, u32 lowest_pn,
|
int (*create_receive_sa)(void *ctx, struct receive_sa *sa);
|
||||||
const u8 *sak);
|
int (*enable_receive_sa)(void *ctx, struct receive_sa *sa);
|
||||||
int (*enable_receive_sa)(void *ctx, u32 channel, u8 an);
|
int (*disable_receive_sa)(void *ctx, struct receive_sa *sa);
|
||||||
int (*disable_receive_sa)(void *ctx, u32 channel, u8 an);
|
|
||||||
int (*get_available_transmit_sc)(void *ctx, u32 *channel);
|
int (*get_available_transmit_sc)(void *ctx, u32 *channel);
|
||||||
int (*create_transmit_sc)(void *ctx, u32 channel,
|
int (*create_transmit_sc)(void *ctx, u32 channel,
|
||||||
const struct ieee802_1x_mka_sci *sci,
|
const struct ieee802_1x_mka_sci *sci,
|
||||||
|
|
|
@ -253,8 +253,7 @@ int secy_create_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ops->create_receive_sa(ops->ctx, rxsa->sc->channel, rxsa->an,
|
return ops->create_receive_sa(ops->ctx, rxsa);
|
||||||
rxsa->lowest_pn, rxsa->pkey->key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -276,7 +275,7 @@ int secy_enable_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
|
||||||
|
|
||||||
rxsa->enable_receive = TRUE;
|
rxsa->enable_receive = TRUE;
|
||||||
|
|
||||||
return ops->enable_receive_sa(ops->ctx, rxsa->sc->channel, rxsa->an);
|
return ops->enable_receive_sa(ops->ctx, rxsa);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -298,7 +297,7 @@ int secy_disable_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
|
||||||
|
|
||||||
rxsa->enable_receive = FALSE;
|
rxsa->enable_receive = FALSE;
|
||||||
|
|
||||||
return ops->disable_receive_sa(ops->ctx, rxsa->sc->channel, rxsa->an);
|
return ops->disable_receive_sa(ops->ctx, rxsa);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -802,29 +802,27 @@ static inline int wpa_drv_delete_receive_sc(struct wpa_supplicant *wpa_s,
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int wpa_drv_create_receive_sa(struct wpa_supplicant *wpa_s,
|
static inline int wpa_drv_create_receive_sa(struct wpa_supplicant *wpa_s,
|
||||||
u32 channel, u8 an,
|
struct receive_sa *sa)
|
||||||
u32 lowest_pn, const u8 *sak)
|
|
||||||
{
|
{
|
||||||
if (!wpa_s->driver->create_receive_sa)
|
if (!wpa_s->driver->create_receive_sa)
|
||||||
return -1;
|
return -1;
|
||||||
return wpa_s->driver->create_receive_sa(wpa_s->drv_priv, channel, an,
|
return wpa_s->driver->create_receive_sa(wpa_s->drv_priv, sa);
|
||||||
lowest_pn, sak);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int wpa_drv_enable_receive_sa(struct wpa_supplicant *wpa_s,
|
static inline int wpa_drv_enable_receive_sa(struct wpa_supplicant *wpa_s,
|
||||||
u32 channel, u8 an)
|
struct receive_sa *sa)
|
||||||
{
|
{
|
||||||
if (!wpa_s->driver->enable_receive_sa)
|
if (!wpa_s->driver->enable_receive_sa)
|
||||||
return -1;
|
return -1;
|
||||||
return wpa_s->driver->enable_receive_sa(wpa_s->drv_priv, channel, an);
|
return wpa_s->driver->enable_receive_sa(wpa_s->drv_priv, sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int wpa_drv_disable_receive_sa(struct wpa_supplicant *wpa_s,
|
static inline int wpa_drv_disable_receive_sa(struct wpa_supplicant *wpa_s,
|
||||||
u32 channel, u8 an)
|
struct receive_sa *sa)
|
||||||
{
|
{
|
||||||
if (!wpa_s->driver->disable_receive_sa)
|
if (!wpa_s->driver->disable_receive_sa)
|
||||||
return -1;
|
return -1;
|
||||||
return wpa_s->driver->disable_receive_sa(wpa_s->drv_priv, channel, an);
|
return wpa_s->driver->disable_receive_sa(wpa_s->drv_priv, sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
|
|
|
@ -117,22 +117,21 @@ static int wpas_delete_receive_sc(void *wpa_s, u32 channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int wpas_create_receive_sa(void *wpa_s, u32 channel, u8 an,
|
static int wpas_create_receive_sa(void *wpa_s, struct receive_sa *sa)
|
||||||
u32 lowest_pn, const u8 *sak)
|
|
||||||
{
|
{
|
||||||
return wpa_drv_create_receive_sa(wpa_s, channel, an, lowest_pn, sak);
|
return wpa_drv_create_receive_sa(wpa_s, sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int wpas_enable_receive_sa(void *wpa_s, u32 channel, u8 an)
|
static int wpas_enable_receive_sa(void *wpa_s, struct receive_sa *sa)
|
||||||
{
|
{
|
||||||
return wpa_drv_enable_receive_sa(wpa_s, channel, an);
|
return wpa_drv_enable_receive_sa(wpa_s, sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int wpas_disable_receive_sa(void *wpa_s, u32 channel, u8 an)
|
static int wpas_disable_receive_sa(void *wpa_s, struct receive_sa *sa)
|
||||||
{
|
{
|
||||||
return wpa_drv_disable_receive_sa(wpa_s, channel, an);
|
return wpa_drv_disable_receive_sa(wpa_s, sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue