mka: Pass full structures down to macsec drivers' transmit SC ops

Clean up the driver interface by passing pointers to struct transmit_sc
down the stack to the {create,delete}_transmit_sc() ops, instead of
passing the individual arguments.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
This commit is contained in:
Sabrina Dubroca 2016-10-07 12:08:09 +02:00 committed by Jouni Malinen
parent b70d508c50
commit 8ebfc7c2ba
6 changed files with 25 additions and 32 deletions

View file

@ -3423,21 +3423,20 @@ struct wpa_driver_ops {
/** /**
* create_transmit_sc - create secure connection for transmit * create_transmit_sc - create secure connection for transmit
* @priv: private driver interface data from init() * @priv: private driver interface data from init()
* @channel: secure channel * @sc: secure channel
* @sci_addr: secure channel identifier - address * @conf_offset: confidentiality offset (0, 30, or 50)
* @sci_port: secure channel identifier - port
* Returns: 0 on success, -1 on failure * Returns: 0 on success, -1 on failure
*/ */
int (*create_transmit_sc)(void *priv, u32 channel, const u8 *sci_addr, int (*create_transmit_sc)(void *priv, struct transmit_sc *sc,
u16 sci_port, unsigned int conf_offset); unsigned int conf_offset);
/** /**
* delete_transmit_sc - delete secure connection for transmit * delete_transmit_sc - delete secure connection for transmit
* @priv: private driver interface data from init() * @priv: private driver interface data from init()
* @channel: secure channel * @sc: secure channel
* Returns: 0 on success, -1 on failure * Returns: 0 on success, -1 on failure
*/ */
int (*delete_transmit_sc)(void *priv, u32 channel); int (*delete_transmit_sc)(void *priv, struct transmit_sc *sc);
/** /**
* create_transmit_sa - create secure association for transmit * create_transmit_sa - create secure association for transmit

View file

@ -750,14 +750,14 @@ static int macsec_qca_get_available_transmit_sc(void *priv, u32 *channel)
} }
static int macsec_qca_create_transmit_sc(void *priv, u32 channel, static int macsec_qca_create_transmit_sc(void *priv, struct transmit_sc *sc,
const u8 *sci_addr, u16 sci_port,
unsigned int conf_offset) unsigned int conf_offset)
{ {
struct macsec_qca_data *drv = priv; struct macsec_qca_data *drv = priv;
int ret = 0; int ret = 0;
fal_tx_class_lut_t entry; fal_tx_class_lut_t entry;
u8 psci[ETH_ALEN + 2]; u8 psci[ETH_ALEN + 2];
u32 channel = sc->channel;
wpa_printf(MSG_DEBUG, "%s: channel=%d", __func__, channel); wpa_printf(MSG_DEBUG, "%s: channel=%d", __func__, channel);
@ -768,9 +768,9 @@ static int macsec_qca_create_transmit_sc(void *priv, u32 channel,
entry.action = FAL_TX_CLASS_ACTION_FORWARD; entry.action = FAL_TX_CLASS_ACTION_FORWARD;
entry.channel = channel; entry.channel = channel;
os_memcpy(psci, sci_addr, ETH_ALEN); os_memcpy(psci, sc->sci.addr, ETH_ALEN);
psci[6] = (sci_port >> 8) & 0xf; psci[6] = (sc->sci.port >> 8) & 0xf;
psci[7] = sci_port & 0xf; psci[7] = sc->sci.port & 0xf;
ret += nss_macsec_secy_tx_class_lut_set(drv->secy_id, channel, &entry); ret += nss_macsec_secy_tx_class_lut_set(drv->secy_id, channel, &entry);
ret += nss_macsec_secy_tx_sc_create(drv->secy_id, channel, psci, 8); ret += nss_macsec_secy_tx_sc_create(drv->secy_id, channel, psci, 8);
@ -784,11 +784,12 @@ static int macsec_qca_create_transmit_sc(void *priv, u32 channel,
} }
static int macsec_qca_delete_transmit_sc(void *priv, u32 channel) static int macsec_qca_delete_transmit_sc(void *priv, struct transmit_sc *sc)
{ {
struct macsec_qca_data *drv = priv; struct macsec_qca_data *drv = priv;
int ret = 0; int ret = 0;
fal_tx_class_lut_t entry; fal_tx_class_lut_t entry;
u32 channel = sc->channel;
wpa_printf(MSG_DEBUG, "%s: channel=%d", __func__, channel); wpa_printf(MSG_DEBUG, "%s: channel=%d", __func__, channel);

View file

@ -155,10 +155,9 @@ struct ieee802_1x_kay_ctx {
int (*enable_receive_sa)(void *ctx, struct receive_sa *sa); int (*enable_receive_sa)(void *ctx, struct receive_sa *sa);
int (*disable_receive_sa)(void *ctx, struct receive_sa *sa); int (*disable_receive_sa)(void *ctx, struct receive_sa *sa);
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, struct transmit_sc *sc,
const struct ieee802_1x_mka_sci *sci,
enum confidentiality_offset co); enum confidentiality_offset co);
int (*delete_transmit_sc)(void *ctx, u32 channel); int (*delete_transmit_sc)(void *ctx, struct transmit_sc *sc);
int (*create_transmit_sa)(void *ctx, struct transmit_sa *sa); int (*create_transmit_sa)(void *ctx, struct transmit_sa *sa);
int (*enable_transmit_sa)(void *ctx, struct transmit_sa *sa); int (*enable_transmit_sa)(void *ctx, struct transmit_sa *sa);
int (*disable_transmit_sa)(void *ctx, struct transmit_sa *sa); int (*disable_transmit_sa)(void *ctx, struct transmit_sa *sa);

View file

@ -338,8 +338,7 @@ int secy_create_transmit_sc(struct ieee802_1x_kay *kay,
return -1; return -1;
} }
return ops->create_transmit_sc(ops->ctx, txsc->channel, &txsc->sci, return ops->create_transmit_sc(ops->ctx, txsc, kay->co);
kay->co);
} }
@ -360,7 +359,7 @@ int secy_delete_transmit_sc(struct ieee802_1x_kay *kay,
return -1; return -1;
} }
return ops->delete_transmit_sc(ops->ctx, txsc->channel); return ops->delete_transmit_sc(ops->ctx, txsc);
} }

View file

@ -835,23 +835,21 @@ wpa_drv_get_available_transmit_sc(struct wpa_supplicant *wpa_s, u32 *channel)
} }
static inline int static inline int
wpa_drv_create_transmit_sc(struct wpa_supplicant *wpa_s, u32 channel, wpa_drv_create_transmit_sc(struct wpa_supplicant *wpa_s, struct transmit_sc *sc,
const u8 *sci_addr, u16 sci_port,
unsigned int conf_offset) unsigned int conf_offset)
{ {
if (!wpa_s->driver->create_transmit_sc) if (!wpa_s->driver->create_transmit_sc)
return -1; return -1;
return wpa_s->driver->create_transmit_sc(wpa_s->drv_priv, channel, return wpa_s->driver->create_transmit_sc(wpa_s->drv_priv, sc,
sci_addr, sci_port,
conf_offset); conf_offset);
} }
static inline int wpa_drv_delete_transmit_sc(struct wpa_supplicant *wpa_s, static inline int wpa_drv_delete_transmit_sc(struct wpa_supplicant *wpa_s,
u32 channel) struct transmit_sc *sc)
{ {
if (!wpa_s->driver->delete_transmit_sc) if (!wpa_s->driver->delete_transmit_sc)
return -1; return -1;
return wpa_s->driver->delete_transmit_sc(wpa_s->drv_priv, channel); return wpa_s->driver->delete_transmit_sc(wpa_s->drv_priv, sc);
} }
static inline int wpa_drv_create_transmit_sa(struct wpa_supplicant *wpa_s, static inline int wpa_drv_create_transmit_sa(struct wpa_supplicant *wpa_s,

View file

@ -142,19 +142,16 @@ static int wpas_get_available_transmit_sc(void *wpa_s, u32 *channel)
static int static int
wpas_create_transmit_sc(void *wpa_s, u32 channel, wpas_create_transmit_sc(void *wpa_s, struct transmit_sc *sc,
const struct ieee802_1x_mka_sci *sci,
enum confidentiality_offset co) enum confidentiality_offset co)
{ {
return wpa_drv_create_transmit_sc(wpa_s, channel, sci->addr, return wpa_drv_create_transmit_sc(wpa_s, sc, conf_offset_val(co));
be_to_host16(sci->port),
conf_offset_val(co));
} }
static int wpas_delete_transmit_sc(void *wpa_s, u32 channel) static int wpas_delete_transmit_sc(void *wpa_s, struct transmit_sc *sc)
{ {
return wpa_drv_delete_transmit_sc(wpa_s, channel); return wpa_drv_delete_transmit_sc(wpa_s, sc);
} }