Lines Matching refs:tx_sa

144 		struct macsec_tx_sa *tx_sa;  member
453 struct macsec_tx_sa *tx_sa) in __macsec_pn_wrapped() argument
456 tx_sa->active = false; in __macsec_pn_wrapped()
461 void macsec_pn_wrapped(struct macsec_secy *secy, struct macsec_tx_sa *tx_sa) in macsec_pn_wrapped() argument
463 spin_lock_bh(&tx_sa->lock); in macsec_pn_wrapped()
464 __macsec_pn_wrapped(secy, tx_sa); in macsec_pn_wrapped()
465 spin_unlock_bh(&tx_sa->lock); in macsec_pn_wrapped()
469 static pn_t tx_sa_update_pn(struct macsec_tx_sa *tx_sa, in tx_sa_update_pn() argument
474 spin_lock_bh(&tx_sa->lock); in tx_sa_update_pn()
476 pn = tx_sa->next_pn_halves; in tx_sa_update_pn()
478 tx_sa->next_pn++; in tx_sa_update_pn()
480 tx_sa->next_pn_halves.lower++; in tx_sa_update_pn()
482 if (tx_sa->next_pn == 0) in tx_sa_update_pn()
483 __macsec_pn_wrapped(secy, tx_sa); in tx_sa_update_pn()
484 spin_unlock_bh(&tx_sa->lock); in tx_sa_update_pn()
499 struct macsec_tx_sa *tx_sa) in macsec_count_tx() argument
507 this_cpu_inc(tx_sa->stats->OutPktsEncrypted); in macsec_count_tx()
511 this_cpu_inc(tx_sa->stats->OutPktsProtected); in macsec_count_tx()
533 struct macsec_tx_sa *sa = macsec_skb_cb(skb)->tx_sa; in macsec_encrypt_done()
540 macsec_count_tx(skb, &macsec->secy.tx_sc, macsec_skb_cb(skb)->tx_sa); in macsec_encrypt_done()
593 struct macsec_tx_sa *tx_sa; in macsec_encrypt() local
602 tx_sa = macsec_txsa_get(tx_sc->sa[tx_sc->encoding_sa]); in macsec_encrypt()
603 if (!tx_sa) { in macsec_encrypt()
619 macsec_txsa_put(tx_sa); in macsec_encrypt()
626 macsec_txsa_put(tx_sa); in macsec_encrypt()
637 pn = tx_sa_update_pn(tx_sa, secy); in macsec_encrypt()
639 macsec_txsa_put(tx_sa); in macsec_encrypt()
655 macsec_txsa_put(tx_sa); in macsec_encrypt()
662 macsec_txsa_put(tx_sa); in macsec_encrypt()
667 req = macsec_alloc_req(tx_sa->key.tfm, &iv, &sg, ret); in macsec_encrypt()
669 macsec_txsa_put(tx_sa); in macsec_encrypt()
675 macsec_fill_iv_xpn(iv, tx_sa->ssci, pn.full64, tx_sa->key.salt); in macsec_encrypt()
683 macsec_txsa_put(tx_sa); in macsec_encrypt()
699 macsec_skb_cb(skb)->tx_sa = tx_sa; in macsec_encrypt()
710 macsec_txsa_put(tx_sa); in macsec_encrypt()
716 macsec_txsa_put(tx_sa); in macsec_encrypt()
1428 static int init_tx_sa(struct macsec_tx_sa *tx_sa, char *sak, int key_len, in init_tx_sa() argument
1431 tx_sa->stats = alloc_percpu(struct macsec_tx_sa_stats); in init_tx_sa()
1432 if (!tx_sa->stats) in init_tx_sa()
1435 tx_sa->key.tfm = macsec_alloc_tfm(sak, key_len, icv_len); in init_tx_sa()
1436 if (IS_ERR(tx_sa->key.tfm)) { in init_tx_sa()
1437 free_percpu(tx_sa->stats); in init_tx_sa()
1438 return PTR_ERR(tx_sa->key.tfm); in init_tx_sa()
1441 tx_sa->ssci = MACSEC_UNDEF_SSCI; in init_tx_sa()
1442 tx_sa->active = false; in init_tx_sa()
1443 refcount_set(&tx_sa->refcnt, 1); in init_tx_sa()
1444 spin_lock_init(&tx_sa->lock); in init_tx_sa()
1449 static void clear_tx_sa(struct macsec_tx_sa *tx_sa) in clear_tx_sa() argument
1451 tx_sa->active = false; in clear_tx_sa()
1453 macsec_txsa_put(tx_sa); in clear_tx_sa()
1511 struct macsec_tx_sa *tx_sa; in get_txsa_from_nl() local
1528 tx_sa = rtnl_dereference(tx_sc->sa[*assoc_num]); in get_txsa_from_nl()
1529 if (!tx_sa) in get_txsa_from_nl()
1535 return tx_sa; in get_txsa_from_nl()
1959 struct macsec_tx_sa *tx_sa; in macsec_add_txsa() local
2017 tx_sa = rtnl_dereference(tx_sc->sa[assoc_num]); in macsec_add_txsa()
2018 if (tx_sa) { in macsec_add_txsa()
2023 tx_sa = kmalloc(sizeof(*tx_sa), GFP_KERNEL); in macsec_add_txsa()
2024 if (!tx_sa) { in macsec_add_txsa()
2029 err = init_tx_sa(tx_sa, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]), in macsec_add_txsa()
2032 kfree(tx_sa); in macsec_add_txsa()
2037 spin_lock_bh(&tx_sa->lock); in macsec_add_txsa()
2038 tx_sa->next_pn = nla_get_u64(tb_sa[MACSEC_SA_ATTR_PN]); in macsec_add_txsa()
2039 spin_unlock_bh(&tx_sa->lock); in macsec_add_txsa()
2042 tx_sa->active = !!nla_get_u8(tb_sa[MACSEC_SA_ATTR_ACTIVE]); in macsec_add_txsa()
2045 if (assoc_num == tx_sc->encoding_sa && tx_sa->active) in macsec_add_txsa()
2060 ctx.sa.tx_sa = tx_sa; in macsec_add_txsa()
2071 tx_sa->ssci = nla_get_ssci(tb_sa[MACSEC_SA_ATTR_SSCI]); in macsec_add_txsa()
2072 nla_memcpy(tx_sa->key.salt.bytes, tb_sa[MACSEC_SA_ATTR_SALT], in macsec_add_txsa()
2076 nla_memcpy(tx_sa->key.id, tb_sa[MACSEC_SA_ATTR_KEYID], MACSEC_KEYID_LEN); in macsec_add_txsa()
2077 rcu_assign_pointer(tx_sc->sa[assoc_num], tx_sa); in macsec_add_txsa()
2085 macsec_txsa_put(tx_sa); in macsec_add_txsa()
2225 struct macsec_tx_sa *tx_sa; in macsec_del_txsa() local
2237 tx_sa = get_txsa_from_nl(genl_info_net(info), attrs, tb_sa, in macsec_del_txsa()
2239 if (IS_ERR(tx_sa)) { in macsec_del_txsa()
2241 return PTR_ERR(tx_sa); in macsec_del_txsa()
2244 if (tx_sa->active) { in macsec_del_txsa()
2261 ctx.sa.tx_sa = tx_sa; in macsec_del_txsa()
2270 clear_tx_sa(tx_sa); in macsec_del_txsa()
2310 struct macsec_tx_sa *tx_sa; in macsec_upd_txsa() local
2329 tx_sa = get_txsa_from_nl(genl_info_net(info), attrs, tb_sa, in macsec_upd_txsa()
2331 if (IS_ERR(tx_sa)) { in macsec_upd_txsa()
2333 return PTR_ERR(tx_sa); in macsec_upd_txsa()
2347 spin_lock_bh(&tx_sa->lock); in macsec_upd_txsa()
2348 prev_pn = tx_sa->next_pn_halves; in macsec_upd_txsa()
2349 tx_sa->next_pn = nla_get_u64(tb_sa[MACSEC_SA_ATTR_PN]); in macsec_upd_txsa()
2350 spin_unlock_bh(&tx_sa->lock); in macsec_upd_txsa()
2353 was_active = tx_sa->active; in macsec_upd_txsa()
2355 tx_sa->active = nla_get_u8(tb_sa[MACSEC_SA_ATTR_ACTIVE]); in macsec_upd_txsa()
2359 secy->operational = tx_sa->active; in macsec_upd_txsa()
2373 ctx.sa.tx_sa = tx_sa; in macsec_upd_txsa()
2387 spin_lock_bh(&tx_sa->lock); in macsec_upd_txsa()
2388 tx_sa->next_pn_halves = prev_pn; in macsec_upd_txsa()
2389 spin_unlock_bh(&tx_sa->lock); in macsec_upd_txsa()
2391 tx_sa->active = was_active; in macsec_upd_txsa()
2662 struct macsec_tx_sa *tx_sa, in get_tx_sa_stats() argument
2676 ctx.sa.tx_sa = tx_sa; in get_tx_sa_stats()
2686 per_cpu_ptr(tx_sa->stats, cpu); in get_tx_sa_stats()
3082 struct macsec_tx_sa *tx_sa = rtnl_dereference(tx_sc->sa[i]); in dump_secy() local
3087 if (!tx_sa) in dump_secy()
3103 get_tx_sa_stats(dev, i, tx_sa, &tx_sa_stats); in dump_secy()
3113 pn = tx_sa->next_pn; in dump_secy()
3116 pn = tx_sa->next_pn_halves.lower; in dump_secy()
3122 nla_put(skb, MACSEC_SA_ATTR_KEYID, MACSEC_KEYID_LEN, tx_sa->key.id) || in dump_secy()
3123 (secy->xpn && nla_put_ssci(skb, MACSEC_SA_ATTR_SSCI, tx_sa->ssci)) || in dump_secy()
3124 nla_put_u8(skb, MACSEC_SA_ATTR_ACTIVE, tx_sa->active)) { in dump_secy()
3409 macsec_count_tx(skb, &macsec->secy.tx_sc, macsec_skb_cb(skb)->tx_sa); in macsec_start_xmit()
3736 struct macsec_tx_sa *tx_sa; in macsec_changelink_common() local
3739 tx_sa = rtnl_dereference(tx_sc->sa[tx_sc->encoding_sa]); in macsec_changelink_common()
3741 secy->operational = tx_sa && tx_sa->active; in macsec_changelink_common()