History

net: dsa: tag_qca: add define for handling mgmt Ethernet packet

Add all the required define to prepare support for mgmt read/write in Ethernet packet. Any packet of this type has to be dropped as the only use of these special packet is receive ack for an mgmt write request or receive data for an mgmt read request. A struct is used that emulates the Ethernet header but is used for a different purpose.

Ansuel Smith committed 4 years ago

Commit c2ee8181 parent 101c04c2 files · +56 −3Browse files

Showing the changes to include/linux/dsa (1 of 2 files). Show all

Unified · Split

include/linux/dsa/tag_qca.h+44−0
@@ -12,10 +12,54 @@ · 11 unmodified lines
1212 #define QCA_HDR_RECV_FRAME_IS_TAGGED BIT(3)
1313 #define QCA_HDR_RECV_SOURCE_PORT GENMASK(2, 0)
1414
15+/* Packet type for recv */
16+#define QCA_HDR_RECV_TYPE_NORMAL 0x0
17+#define QCA_HDR_RECV_TYPE_MIB 0x1
18+#define QCA_HDR_RECV_TYPE_RW_REG_ACK 0x2
19+
1520 #define QCA_HDR_XMIT_VERSION GENMASK(15, 14)
1621 #define QCA_HDR_XMIT_PRIORITY GENMASK(13, 11)
1722 #define QCA_HDR_XMIT_CONTROL GENMASK(10, 8)
1823 #define QCA_HDR_XMIT_FROM_CPU BIT(7)
1924 #define QCA_HDR_XMIT_DP_BIT GENMASK(6, 0)
2025
26+/* Packet type for xmit */
27+#define QCA_HDR_XMIT_TYPE_NORMAL 0x0
28+#define QCA_HDR_XMIT_TYPE_RW_REG 0x1
29+
30+/* Check code for a valid mgmt packet. Switch will ignore the packet
31+ * with this wrong.
32+ */
33+#define QCA_HDR_MGMT_CHECK_CODE_VAL 0x5
34+
35+/* Specific define for in-band MDIO read/write with Ethernet packet */
36+#define QCA_HDR_MGMT_SEQ_LEN 4 /* 4 byte for the seq */
37+#define QCA_HDR_MGMT_COMMAND_LEN 4 /* 4 byte for the command */
38+#define QCA_HDR_MGMT_DATA1_LEN 4 /* First 4 byte for the mdio data */
39+#define QCA_HDR_MGMT_HEADER_LEN (QCA_HDR_MGMT_SEQ_LEN + \
40+ QCA_HDR_MGMT_COMMAND_LEN + \
41+ QCA_HDR_MGMT_DATA1_LEN)
42+
43+#define QCA_HDR_MGMT_DATA2_LEN 12 /* Other 12 byte for the mdio data */
44+#define QCA_HDR_MGMT_PADDING_LEN 34 /* Padding to reach the min Ethernet packet */
45+
46+#define QCA_HDR_MGMT_PKT_LEN (QCA_HDR_MGMT_HEADER_LEN + \
47+ QCA_HDR_LEN + \
48+ QCA_HDR_MGMT_DATA2_LEN + \
49+ QCA_HDR_MGMT_PADDING_LEN)
50+
51+#define QCA_HDR_MGMT_SEQ_NUM GENMASK(31, 0) /* 63, 32 */
52+#define QCA_HDR_MGMT_CHECK_CODE GENMASK(31, 29) /* 31, 29 */
53+#define QCA_HDR_MGMT_CMD BIT(28) /* 28 */
54+#define QCA_HDR_MGMT_LENGTH GENMASK(23, 20) /* 23, 20 */
55+#define QCA_HDR_MGMT_ADDR GENMASK(18, 0) /* 18, 0 */
56+
57+/* Special struct emulating a Ethernet header */
58+struct qca_mgmt_ethhdr {
59+ u32 command; /* command bit 31:0 */
60+ u32 seq; /* seq 63:32 */
61+ u32 mdio_data; /* first 4byte mdio */
62+ __be16 hdr; /* qca hdr */
63+} __packed;
64+
2165 #endif /* __TAG_QCA_H */