13c4542b2SWei Fang /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ 23c4542b2SWei Fang /* 33c4542b2SWei Fang * Copyright 2025-2026 NXP 43c4542b2SWei Fang * 53c4542b2SWei Fang * The VSI-to-PSI message generic format: 63c4542b2SWei Fang * 73c4542b2SWei Fang * OFFSET 0 16 24 31 83c4542b2SWei Fang * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 93c4542b2SWei Fang * 0x0 | CRC16 (big-endian) | CLASS ID | CMD ID | 103c4542b2SWei Fang * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 113c4542b2SWei Fang * 0x4 | PROTO VER | LEN | RESV | COOKIE| RESV | 123c4542b2SWei Fang * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 133c4542b2SWei Fang * 0x8 | RESV | 143c4542b2SWei Fang * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 153c4542b2SWei Fang * 0xc | RESV | 163c4542b2SWei Fang * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 173c4542b2SWei Fang * 0x10 | | 183c4542b2SWei Fang * 0x14 | | 193c4542b2SWei Fang * 0x18 | Message Body | 203c4542b2SWei Fang * 0x1c | | 213c4542b2SWei Fang * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 223c4542b2SWei Fang * 0x20 | | 233c4542b2SWei Fang * ~ | Extended Message Body: LEN x 32B | 243c4542b2SWei Fang * 0x3e0 | | 253c4542b2SWei Fang * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 263c4542b2SWei Fang * 273c4542b2SWei Fang * Field Descriptions: 283c4542b2SWei Fang * CRC16 (16-bit): Big endian, CRC16 CCITT-FALSE algorithm, It provides the 293c4542b2SWei Fang * equivalent data integrity check functionality as the FCS for standard 303c4542b2SWei Fang * Ethernet frames. 313c4542b2SWei Fang * 323c4542b2SWei Fang * CLASS ID (8-bit) and CMD ID (8-bit): These are 8-bit fields identifying 333c4542b2SWei Fang * the command class and the class-specific operations supported. For more 343c4542b2SWei Fang * details, please refer to the definitions of the relevant class ID and 353c4542b2SWei Fang * cmd ID in this document. 363c4542b2SWei Fang * 373c4542b2SWei Fang * PROTO VER (8-bit): Supported VSI-PSI command protocol version. Currently 383c4542b2SWei Fang * only support version 0. To be incremented for future protocol extensions. 393c4542b2SWei Fang * 403c4542b2SWei Fang * LEN (8-bit): Extended message body length in increments of 32B. The upper 413c4542b2SWei Fang * limit is given by the physical implementation of the NETC VSI-PSI Messaging 423c4542b2SWei Fang * mechanism that supports message sizes of up to 1024B (including headers), 433c4542b2SWei Fang * that are multiple of 32B. 443c4542b2SWei Fang * 453c4542b2SWei Fang * COOKIE (4-bit): Optional parameter, which, if not 0, indicates that the 463c4542b2SWei Fang * command should be execute asynchronously on PSI side. If COOKIE is not 0 473c4542b2SWei Fang * and the command cannot be executed instantly on the PSI side (it would 483c4542b2SWei Fang * take longer time to complete), the PSI may enqueue the request in a command 493c4542b2SWei Fang * queue of up to 15 entries per VSI and, later after command execution, the 503c4542b2SWei Fang * PSI returns the COOKIE to VSI as part of an asynchronous notification 513c4542b2SWei Fang * message that indicates the command completion status. If COOKIE is 0 then 523c4542b2SWei Fang * the command is considered as blocking, the PSI will wait for the execution 533c4542b2SWei Fang * of the command to complete before updating the PSIMSGRR[MC] field with the 543c4542b2SWei Fang * corresponding return code. 553c4542b2SWei Fang * 563c4542b2SWei Fang * The PSI-to-VSI message generic format: 573c4542b2SWei Fang * 0 4 8 12 15 583c4542b2SWei Fang * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 593c4542b2SWei Fang * | COOKIE | CLASS CODE | CLASS ID | 603c4542b2SWei Fang * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 613c4542b2SWei Fang * 623c4542b2SWei Fang * The PSI to VSI message format is mapped to the following PSI message 633c4542b2SWei Fang * registers/fields, depending on use case: 643c4542b2SWei Fang * 1) PSI_RX_control: PSIMSGRR[MC] - for VSI command return code messages 653c4542b2SWei Fang * (blocking requests), and 663c4542b2SWei Fang * 2) PSI_TX_control: PSIMSGSR[MC] - for PSI to VSI notification messages 673c4542b2SWei Fang * (async mode) 68*72037f95SWei Fang * 69*72037f95SWei Fang * Note that for some GET messages, there is no COOKIE field, and the CLASS 70*72037f95SWei Fang * CODE field is expanded to 8 bits. 713c4542b2SWei Fang */ 723c4542b2SWei Fang 733c4542b2SWei Fang #ifndef __ENETC_MAILBOX_H 743c4542b2SWei Fang #define __ENETC_MAILBOX_H 753c4542b2SWei Fang 763c4542b2SWei Fang #include <linux/crc-itu-t.h> 773c4542b2SWei Fang 783c4542b2SWei Fang #define ENETC_CRC_INIT 0xffff 793c4542b2SWei Fang #define ENETC_MSG_ALIGN 32 803c4542b2SWei Fang /* s indicates the size of the message */ 813c4542b2SWei Fang #define ENETC_MSG_EXT_BODY_LEN(s) ((s) / ENETC_MSG_ALIGN - 1) 823c4542b2SWei Fang /* l indicates the extended body len (LEN field) of the message */ 833c4542b2SWei Fang #define ENETC_MSG_SIZE(l) (((l) + 1) * ENETC_MSG_ALIGN) 843c4542b2SWei Fang 853c4542b2SWei Fang /* The cookie filed of VSI-to-PSI message */ 863c4542b2SWei Fang #define ENETC_VF_MSG_COOKIE GENMASK(3, 0) 873c4542b2SWei Fang /* The fileds of PSI-to-VSI message, the message is only 16-bit */ 883c4542b2SWei Fang #define ENETC_PF_MSG_COOKIE GENMASK(3, 0) 893c4542b2SWei Fang #define ENETC_PF_MSG_CLASS_CODE GENMASK(7, 4) 90*72037f95SWei Fang /* Extend the class code to 8-bit for GET messages without COOKIE */ 91*72037f95SWei Fang #define ENETC_PF_MSG_CLASS_CODE_U8 GENMASK(7, 0) 923c4542b2SWei Fang #define ENETC_PF_MSG_CLASS_ID GENMASK(15, 8) 933c4542b2SWei Fang 943c4542b2SWei Fang enum enetc_msg_class_id { 953c4542b2SWei Fang /* Class ID for PSI-to-VSI messages */ 963c4542b2SWei Fang ENETC_MSG_CLASS_ID_CMD_SUCCESS = 1, 973c4542b2SWei Fang ENETC_MSG_CLASS_ID_PERMISSION_DENY, 983c4542b2SWei Fang ENETC_MSG_CLASS_ID_CMD_NOT_SUPPORT, 993c4542b2SWei Fang ENETC_MSG_CLASS_ID_PSI_BUSY, 1003c4542b2SWei Fang ENETC_MSG_CLASS_ID_CRC_ERROR, 1013c4542b2SWei Fang ENETC_MSG_CLASS_ID_PROTO_NOT_SUPPORT, 1023c4542b2SWei Fang ENETC_MSG_CLASS_ID_INVALID_MSG_LEN, 1033c4542b2SWei Fang ENETC_MSG_CLASS_ID_CMD_TIMEOUT, 1043c4542b2SWei Fang ENETC_MSG_CLASS_ID_CMD_NOT_PERMITTED, 1053c4542b2SWei Fang ENETC_MSG_CLASS_ID_CMD_FAIL, /* Generic error code for failure */ 1063c4542b2SWei Fang ENETC_MSG_CLASS_ID_CMD_DEFERRED = 0xf, 1073c4542b2SWei Fang 1083c4542b2SWei Fang /* Common Class ID for PSI-to-VSI and VSI-to-PSI messages */ 1093c4542b2SWei Fang ENETC_MSG_CLASS_ID_MAC_FILTER = 0x20, 110*72037f95SWei Fang ENETC_MSG_CLASS_ID_IP_REVISION = 0xf0, 1113c4542b2SWei Fang }; 1123c4542b2SWei Fang 1133c4542b2SWei Fang enum enetc_msg_mac_filter_cmd_id { 1143c4542b2SWei Fang ENETC_MSG_SET_PRIMARY_MAC, 1153c4542b2SWei Fang }; 1163c4542b2SWei Fang 117*72037f95SWei Fang enum enetc_msg_ip_revision_cmd_id { 118*72037f95SWei Fang ENETC_MSG_GET_IP_MN = 1, 119*72037f95SWei Fang }; 120*72037f95SWei Fang 1213c4542b2SWei Fang /* Class-specific error return codes of MAC filter */ 1223c4542b2SWei Fang enum enetc_mac_filter_class_code { 1233c4542b2SWei Fang ENETC_MF_CLASS_CODE_INVALID_MAC, 1243c4542b2SWei Fang }; 1253c4542b2SWei Fang 1263c4542b2SWei Fang struct enetc_msg_swbd { 1273c4542b2SWei Fang void *vaddr; 1283c4542b2SWei Fang dma_addr_t dma; 1293c4542b2SWei Fang int size; 1303c4542b2SWei Fang }; 1313c4542b2SWei Fang 1323c4542b2SWei Fang /* The generic VSI-to-PSI message header */ 1333c4542b2SWei Fang struct enetc_msg_header { 1343c4542b2SWei Fang __be16 crc16; 1353c4542b2SWei Fang u8 class_id; 1363c4542b2SWei Fang u8 cmd_id; 1373c4542b2SWei Fang u8 proto_ver; 1383c4542b2SWei Fang u8 len; 1393c4542b2SWei Fang u8 resv0; 1403c4542b2SWei Fang u8 cookie; 1413c4542b2SWei Fang u8 resv2[8]; 1423c4542b2SWei Fang }; 1433c4542b2SWei Fang 1443c4542b2SWei Fang struct enetc_mac_addr { 1453c4542b2SWei Fang u8 addr[ETH_ALEN]; /* Network byte order */ 1463c4542b2SWei Fang }; 1473c4542b2SWei Fang 1483c4542b2SWei Fang /* Message format of class_id 0x20 for exact MAC filter. 1493c4542b2SWei Fang * cmd_id 0x0: set primary MAC 1503c4542b2SWei Fang * cmd_id 0x1: Add entries to MAC address filter table 1513c4542b2SWei Fang * cmd_id 0x2: Delete entries from MAC address filter table 1523c4542b2SWei Fang * Note that cmd_id 0x1 and 0x2 are not supported yet. 1533c4542b2SWei Fang */ 1543c4542b2SWei Fang struct enetc_msg_mac_exact_filter { 1553c4542b2SWei Fang struct enetc_msg_header hdr; 1563c4542b2SWei Fang u8 mac_cnt; /* No need to set for cmd_id 0 */ 1573c4542b2SWei Fang u8 resv[3]; 1583c4542b2SWei Fang struct enetc_mac_addr mac[]; 1593c4542b2SWei Fang }; 1603c4542b2SWei Fang 161*72037f95SWei Fang /* The generic message format applies to the following messages: 162*72037f95SWei Fang * Get IP revision message, class_id 0xf0. 163*72037f95SWei Fang * cmd_id 1: get IP minor revision 164*72037f95SWei Fang */ 165*72037f95SWei Fang struct enetc_msg_generic { 166*72037f95SWei Fang struct enetc_msg_header hdr; 167*72037f95SWei Fang u8 resv[16]; 168*72037f95SWei Fang }; 169*72037f95SWei Fang 1703c4542b2SWei Fang #endif 171