]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: dsa: sja1105: make the AVB table dynamically reconfigurable
authorVladimir Oltean <vladimir.oltean@nxp.com>
Mon, 23 Mar 2020 22:59:23 +0000 (00:59 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 24 Mar 2020 05:15:07 +0000 (22:15 -0700)
The AVB table contains the CAS_MASTER field (to be added in the next
patch) which decides the direction of the PTP_CLK pin.

Reconfiguring this field dynamically is highly preferable to having to
reset the switch and upload a new static configuration, so we add
support for exactly that.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/sja1105/sja1105.h
drivers/net/dsa/sja1105/sja1105_dynamic_config.c
drivers/net/dsa/sja1105/sja1105_static_config.c

index 4c40f2d51a54fd52a023069ab6f29fcf7e58edc2..5bc40175ee0d8dd8709b8af4350ed67bdf7efea3 100644 (file)
@@ -214,5 +214,7 @@ size_t sja1105_vlan_lookup_entry_packing(void *buf, void *entry_ptr,
                                         enum packing_op op);
 size_t sja1105pqrs_mac_config_entry_packing(void *buf, void *entry_ptr,
                                            enum packing_op op);
+size_t sja1105pqrs_avb_params_entry_packing(void *buf, void *entry_ptr,
+                                           enum packing_op op);
 
 #endif
index 25381bd65ed792ba2eed610a3744a714d6bdfe19..bf9b36ff35bf904b47ee51997106d13c0d56d675 100644 (file)
 #define SJA1105ET_SIZE_GENERAL_PARAMS_DYN_CMD                  \
        SJA1105_SIZE_DYN_CMD
 
+#define SJA1105PQRS_SIZE_AVB_PARAMS_DYN_CMD                    \
+       (SJA1105_SIZE_DYN_CMD + SJA1105PQRS_SIZE_AVB_PARAMS_ENTRY)
+
 #define SJA1105_MAX_DYN_CMD_SIZE                               \
        SJA1105PQRS_SIZE_MAC_CONFIG_DYN_CMD
 
@@ -481,6 +484,18 @@ sja1105et_general_params_entry_packing(void *buf, void *entry_ptr,
        return 0;
 }
 
+static void
+sja1105pqrs_avb_params_cmd_packing(void *buf, struct sja1105_dyn_cmd *cmd,
+                                  enum packing_op op)
+{
+       u8 *p = buf + SJA1105PQRS_SIZE_AVB_PARAMS_ENTRY;
+       const int size = SJA1105_SIZE_DYN_CMD;
+
+       sja1105_packing(p, &cmd->valid,   31, 31, size, op);
+       sja1105_packing(p, &cmd->errors,  30, 30, size, op);
+       sja1105_packing(p, &cmd->rdwrset, 29, 29, size, op);
+}
+
 #define OP_READ                BIT(0)
 #define OP_WRITE       BIT(1)
 #define OP_DEL         BIT(2)
@@ -610,7 +625,14 @@ struct sja1105_dynamic_table_ops sja1105pqrs_dyn_ops[BLK_IDX_MAX_DYN] = {
                .addr = 0x38,
        },
        [BLK_IDX_L2_FORWARDING_PARAMS] = {0},
-       [BLK_IDX_AVB_PARAMS] = {0},
+       [BLK_IDX_AVB_PARAMS] = {
+               .entry_packing = sja1105pqrs_avb_params_entry_packing,
+               .cmd_packing = sja1105pqrs_avb_params_cmd_packing,
+               .max_entry_count = SJA1105_MAX_AVB_PARAMS_COUNT,
+               .access = (OP_READ | OP_WRITE),
+               .packed_size = SJA1105PQRS_SIZE_AVB_PARAMS_DYN_CMD,
+               .addr = 0x8003,
+       },
        [BLK_IDX_GENERAL_PARAMS] = {
                .entry_packing = sja1105et_general_params_entry_packing,
                .cmd_packing = sja1105et_general_params_cmd_packing,
index 63d2311817c474a460ac26218c93dacfe0678aa7..fccc9c4d6b35560320850915e14ea2098ae80c8a 100644 (file)
@@ -102,8 +102,8 @@ static size_t sja1105et_avb_params_entry_packing(void *buf, void *entry_ptr,
        return size;
 }
 
-static size_t sja1105pqrs_avb_params_entry_packing(void *buf, void *entry_ptr,
-                                                  enum packing_op op)
+size_t sja1105pqrs_avb_params_entry_packing(void *buf, void *entry_ptr,
+                                           enum packing_op op)
 {
        const size_t size = SJA1105PQRS_SIZE_AVB_PARAMS_ENTRY;
        struct sja1105_avb_params_entry *entry = entry_ptr;