Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: phy: nxp-c45-tja11xx: implement mdo_insert_tx_tag

Implement mdo_insert_tx_tag to insert the TLV header in the ethernet
frame.

Signed-off-by: Radu Pirea (NXP OSS) <radu-nicolae.pirea@oss.nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Radu Pirea (NXP OSS) and committed by
David S. Miller
dc1a0038 31a99fc0

+41
+41
drivers/net/phy/nxp-c45-tja11xx-macsec.c
··· 11 11 #include <linux/module.h> 12 12 #include <linux/phy.h> 13 13 #include <linux/processor.h> 14 + #include <net/dst_metadata.h> 14 15 #include <net/macsec.h> 15 16 16 17 #include "nxp-c45-tja11xx.h" ··· 119 118 #define ADPTR_CNTRL 0x0F00 120 119 #define ADPTR_CNTRL_CONFIG_EN BIT(14) 121 120 #define ADPTR_CNTRL_ADPTR_EN BIT(12) 121 + #define ADPTR_TX_TAG_CNTRL 0x0F0C 122 + #define ADPTR_TX_TAG_CNTRL_ENA BIT(31) 122 123 123 124 #define TX_SC_FLT_BASE 0x800 124 125 #define TX_SC_FLT_SIZE 0x10 ··· 168 165 #define MACSEC_INPWTS 0x0630 169 166 #define MACSEC_INPBTS 0x0638 170 167 #define MACSEC_IPSNFS 0x063C 168 + 169 + #define TJA11XX_TLV_TX_NEEDED_HEADROOM (32) 170 + #define TJA11XX_TLV_NEEDED_TAILROOM (0) 171 + 172 + #define ETH_P_TJA11XX_TLV (0x4e58) 171 173 172 174 enum nxp_c45_sa_type { 173 175 TX_SA, ··· 1551 1543 return 0; 1552 1544 } 1553 1545 1546 + struct tja11xx_tlv_header { 1547 + struct ethhdr eth; 1548 + u8 subtype; 1549 + u8 len; 1550 + u8 payload[28]; 1551 + }; 1552 + 1553 + static int nxp_c45_mdo_insert_tx_tag(struct phy_device *phydev, 1554 + struct sk_buff *skb) 1555 + { 1556 + struct tja11xx_tlv_header *tlv; 1557 + struct ethhdr *eth; 1558 + 1559 + eth = eth_hdr(skb); 1560 + tlv = skb_push(skb, TJA11XX_TLV_TX_NEEDED_HEADROOM); 1561 + memmove(tlv, eth, sizeof(*eth)); 1562 + skb_reset_mac_header(skb); 1563 + tlv->eth.h_proto = htons(ETH_P_TJA11XX_TLV); 1564 + tlv->subtype = 1; 1565 + tlv->len = sizeof(tlv->payload); 1566 + memset(tlv->payload, 0, sizeof(tlv->payload)); 1567 + 1568 + return 0; 1569 + } 1570 + 1554 1571 static const struct macsec_ops nxp_c45_macsec_ops = { 1555 1572 .mdo_dev_open = nxp_c45_mdo_dev_open, 1556 1573 .mdo_dev_stop = nxp_c45_mdo_dev_stop, ··· 1596 1563 .mdo_get_tx_sa_stats = nxp_c45_mdo_get_tx_sa_stats, 1597 1564 .mdo_get_rx_sc_stats = nxp_c45_mdo_get_rx_sc_stats, 1598 1565 .mdo_get_rx_sa_stats = nxp_c45_mdo_get_rx_sa_stats, 1566 + .mdo_insert_tx_tag = nxp_c45_mdo_insert_tx_tag, 1567 + .needed_headroom = TJA11XX_TLV_TX_NEEDED_HEADROOM, 1568 + .needed_tailroom = TJA11XX_TLV_NEEDED_TAILROOM, 1599 1569 }; 1600 1570 1601 1571 int nxp_c45_macsec_config_init(struct phy_device *phydev) ··· 1616 1580 1617 1581 ret = nxp_c45_macsec_write(phydev, ADPTR_CNTRL, ADPTR_CNTRL_CONFIG_EN | 1618 1582 ADPTR_CNTRL_ADPTR_EN); 1583 + if (ret) 1584 + return ret; 1585 + 1586 + ret = nxp_c45_macsec_write(phydev, ADPTR_TX_TAG_CNTRL, 1587 + ADPTR_TX_TAG_CNTRL_ENA); 1619 1588 if (ret) 1620 1589 return ret; 1621 1590