openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

macsecphy.h (5201B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      6  *
      7  * File:        macsecphy.h
      8  *
      9  * Header file for MACSEC PHYs
     10  */
     11 #ifndef SOC_MACSECPHY_H
     12 #define SOC_MACSECPHY_H
     13 
     14 
     15 #include <soc/phy/phyctrl.h>
     16 #ifdef INCLUDE_MACSEC
     17 
     18 #include <bmacsec.h>
     19 
     20 typedef bmacsec_dev_addr_t soc_macsec_dev_addr_t;
     21 
     22 extern int 
     23 soc_macsecphy_miim_write(soc_macsec_dev_addr_t dev_addr, 
     24                          uint32 phy_reg_addr, uint16 data);
     25 
     26 extern int 
     27 soc_macsecphy_miim_read(soc_macsec_dev_addr_t dev_addr, 
     28                         uint32 phy_reg_addr, uint16 *data);
     29 
     30 /*
     31  * Create a unique MACSEC portId for specified macsec port
     32  * connected to unit/port.
     33  */
     34 #define SOC_MACSEC_PORTID(u, p) (((u) << 16) | ((p) & 0xff))
     35 
     36 /*
     37  * Return port number within BCM unit from macsec portId.
     38  */
     39 #define SOC_MACSEC_PORTID2UNIT(p)   ((p) >> 16)
     40 
     41 /*
     42  * Return BCM unit number from macsec portId.
     43  */
     44 #define SOC_MACSEC_PORTID2PORT(p)   ((p) & 0xff)
     45 
     46 /*
     47  * Create MACSEC MDIO address.
     48  */
     49 #ifdef BCM_SWITCHMACSEC_SUPPORT
     50 /* nophy_macsec(i.e. switch_macsec) at bit 9 as a flag to indicate this 
     51  * MACSEC of this port is nophy_macsec. 
     52  *
     53  * Design for Switch-MACSEC on SOC_MACSECPHY_MDIO_ADDR() is to replace 
     54  *  'clause45' to 'flags'. This is for the flexible designing purpose and 
     55  *  compatiable with existing design for the PHY bounded MACSEC(PHY-MACSEC)
     56  *  solution. 
     57  *  - the compare between SOC_MACSECPHY_MDIO_ADDR(unit, mdio, flags) and 
     58  *      SOC_MACSECPHY_MDIO_ADDR(unit, mdio, clause45) are 
     59  *      1. 'CLAUSE45' information in both definitions are at bit8 in the 
     60  *          output MDIO_ADDR.
     61  *      2. 'NOPHY_MACSEC' information is at bit9 and is supported in  
     62  *          SOC_MACSECPHY_MDIO_ADDR(unit, mdio, flags) only.
     63  */
     64 
     65 #define SOC_MACSECPHY_MDIO_FLAGS_CLAUSE45   (0x1)   /* flag : clause45 */
     66 #define SOC_MACSECPHY_MDIO_FLAGS_NOPHY      (0x2)   /* flag : nophy_macsec */
     67 #define SOC_MACSECPHY_MDIO_FLAGS_MASK   \
     68         (SOC_MACSECPHY_MDIO_FLAGS_CLAUSE45 | SOC_MACSECPHY_MDIO_FLAGS_NOPHY)
     69 #define SOC_MACSECPHY_MDIO_ADDR(unit, mdio, flags) \
     70                         ((((unit) & 0xff) << 24)    |       \
     71                          (((mdio) & 0xff) << 0)     |       \
     72                          (((flags) & SOC_MACSECPHY_MDIO_FLAGS_MASK) << 8))
     73 #else   /* BCM_SWITCHMACSEC_SUPPORT */
     74 #define SOC_MACSECPHY_MDIO_ADDR(unit, mdio, clause45) \
     75                         ((((unit) & 0xff) << 24)    |       \
     76                          (((mdio) & 0x3ff) << 0)     |       \
     77                          (((clause45) & 0x1) << 11))
     78 #endif  /* BCM_SWITCHMACSEC_SUPPORT */
     79 
     80 #define SOC_MACSECPHY_ADDR2UNIT(a)  (((a) >> 24) & 0xff)
     81 
     82 #define SOC_MACSECPHY_ADDR2MDIO(a)  ((a) & 0x3ff)
     83 
     84 #define SOC_MACSECPHY_ADDR_IS_CLAUSE45(a)  (((a) >> 11) & 1)
     85 
     86 #ifdef BCM_SWITCHMACSEC_SUPPORT
     87 #define SOC_MACSECPHY_ADDR_FLAGS_GET(a)  \
     88         (((a) >> 8) & SOC_MACSECPHY_MDIO_FLAGS_MASK)
     89 #define SOC_MACSECPHY_ADDR_IS_FLAG_CLAUSE45(a)  \
     90         (SOC_MACSECPHY_ADDR_FLAGS_GET(a) & SOC_MACSECPHY_MDIO_FLAGS_CLAUSE45)
     91 #define SOC_MACSECPHY_ADDR_IS_FLAG_NOPHY(a)  \
     92         (SOC_MACSECPHY_ADDR_FLAGS_GET(a) & SOC_MACSECPHY_MDIO_FLAGS_NOPHY)
     93 
     94 
     95 
     96 #define SOC_NOPHY_MACSEC_CORE_GET(unit, core, dev_port_cnt)   \
     97         do {    \
     98             (core) = BMACSEC_CORE_UNKNOWN; \
     99             (dev_port_cnt) = 0; \
    100         } while (0)
    101 #define SOC_NOPHY_MACSEC_MAC_GET(unit, mac) \
    102         do {    \
    103             (mac) = BMACSEC_MAC_CORE_UNKNOWN;   \
    104         } while (0)
    105 #define SOC_NOPHY_MACSEC_MMI_GET(unit, iofn)    \
    106         do {    \
    107             (iofn) = NULL; \
    108         } while (0)
    109 #define SOC_NOPHY_MACSEC_DEVID_GET(unit, port, devid) \
    110         do {    \
    111             (devid) = -1; \
    112         } while (0)
    113 
    114 #endif  /* BCM_SWITCHMACSEC_SUPPORT */
    115 
    116 /* --- MACSEC device control type --- 
    117  *
    118  *  Types defined here are used for soc_macsecphy_dev_control_get()/set(), to 
    119  *  control whole MACSEC unit. For example, the request to enable or disable 
    120  *  MACSEC control path, to reset or power-down MACSEC unit.
    121  */
    122 #define SOC_MACSECPHY_DEV_CONTROL_BYPASS    (0x1)
    123 #define SOC_MACSECPHY_DEV_CONTROL_POWERDOWN (0x2)
    124 #define SOC_MACSECPHY_DEV_CONTROL_RESET     (0x3)
    125 
    126 /* --- MACSEC device information type --- 
    127  *
    128  *  Types defined here are used for soc_macsecphy_dev_info_get() for the 
    129  *  purpose to report the MACSEC related information.
    130  */
    131 #define SOC_MACSECPHY_DEV_INFO_SWITCHMACSEC_ATTACHED    (0x1)
    132 
    133 
    134 extern int
    135 soc_macsecphy_init(int unit, soc_port_t port, phy_ctrl_t *pc, 
    136                    bmacsec_core_t core_type, bmacsec_dev_io_f iofn);
    137 
    138 #ifdef BCM_SWITCHMACSEC_SUPPORT
    139 extern int 
    140 soc_switchmacsec_init(int unit, soc_port_t port);
    141 #endif  /* BCM_SWITCHMACSEC_SUPPORT */
    142 
    143 extern int 
    144 soc_macsecphy_dev_control_set(int unit, soc_port_t port, 
    145                     int type, uint32 value);
    146 extern int 
    147 soc_macsecphy_dev_control_get(int unit, soc_port_t port, 
    148                     int type, uint32 *value);
    149 extern int 
    150 soc_macsecphy_dev_info_get(int unit, soc_port_t port, 
    151                     int type, uint32 *value);
    152 
    153 #endif /* INCLUDE_MACSEC */
    154 #endif /* SOC_MACSECPHY_H */
    155