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

net: airoha: Fix VIP configuration for AN7583 SoC

EN7581 and AN7583 SoCs have different VIP definitions. Introduce
get_vip_port callback in airoha_eth_soc_data struct in order to take
into account EN7581 and AN7583 VIP register layout and definition
differences.
Introduce nbq parameter in airoha_gdm_port struct. At the moment nbq
is set statically to value previously used in airhoha_set_gdm2_loopback
routine and it will be read from device tree in subsequent patches.

Fixes: e4e5ce823bdd ("net: airoha: Add AN7583 SoC support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://patch.msgid.link/20260412-airoha-7583-vip-fix-v1-1-c35e02b054bb@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Lorenzo Bianconi and committed by
Paolo Abeni
1acdfbdb f7cf8ece

+51 -17
+49 -17
drivers/net/ethernet/airoha/airoha_eth.c
··· 107 107 struct airoha_eth *eth = port->qdma->eth; 108 108 u32 vip_port; 109 109 110 - switch (port->id) { 111 - case AIROHA_GDM3_IDX: 112 - /* FIXME: handle XSI_PCIE1_PORT */ 113 - vip_port = XSI_PCIE0_VIP_PORT_MASK; 114 - break; 115 - case AIROHA_GDM4_IDX: 116 - /* FIXME: handle XSI_USB_PORT */ 117 - vip_port = XSI_ETH_VIP_PORT_MASK; 118 - break; 119 - default: 120 - return 0; 121 - } 122 - 110 + vip_port = eth->soc->ops.get_vip_port(port, port->nbq); 123 111 if (enable) { 124 112 airoha_fe_set(eth, REG_FE_VIP_PORT_EN, vip_port); 125 113 airoha_fe_set(eth, REG_FE_IFC_PORT_EN, vip_port); ··· 1698 1710 static int airhoha_set_gdm2_loopback(struct airoha_gdm_port *port) 1699 1711 { 1700 1712 struct airoha_eth *eth = port->qdma->eth; 1701 - u32 val, pse_port, chan, nbq; 1713 + u32 val, pse_port, chan; 1702 1714 int src_port; 1703 1715 1704 1716 /* Forward the traffic to the proper GDM port */ ··· 1728 1740 airoha_fe_clear(eth, REG_FE_VIP_PORT_EN, BIT(AIROHA_GDM2_IDX)); 1729 1741 airoha_fe_clear(eth, REG_FE_IFC_PORT_EN, BIT(AIROHA_GDM2_IDX)); 1730 1742 1731 - /* XXX: handle XSI_USB_PORT and XSI_PCE1_PORT */ 1732 - nbq = port->id == AIROHA_GDM3_IDX && airoha_is_7581(eth) ? 4 : 0; 1733 - src_port = eth->soc->ops.get_src_port_id(port, nbq); 1743 + src_port = eth->soc->ops.get_src_port_id(port, port->nbq); 1734 1744 if (src_port < 0) 1735 1745 return src_port; 1736 1746 ··· 2937 2951 port->qdma = qdma; 2938 2952 port->dev = dev; 2939 2953 port->id = id; 2954 + /* XXX: Read nbq from DTS */ 2955 + port->nbq = id == AIROHA_GDM3_IDX && airoha_is_7581(eth) ? 4 : 0; 2940 2956 eth->ports[p] = port; 2941 2957 2942 2958 return airoha_metadata_dst_alloc(port); ··· 3140 3152 return -EINVAL; 3141 3153 } 3142 3154 3155 + static u32 airoha_en7581_get_vip_port(struct airoha_gdm_port *port, int nbq) 3156 + { 3157 + switch (port->id) { 3158 + case AIROHA_GDM3_IDX: 3159 + if (nbq == 4) 3160 + return XSI_PCIE0_VIP_PORT_MASK; 3161 + if (nbq == 5) 3162 + return XSI_PCIE1_VIP_PORT_MASK; 3163 + break; 3164 + case AIROHA_GDM4_IDX: 3165 + if (!nbq) 3166 + return XSI_ETH_VIP_PORT_MASK; 3167 + if (nbq == 1) 3168 + return XSI_USB_VIP_PORT_MASK; 3169 + break; 3170 + default: 3171 + break; 3172 + } 3173 + 3174 + return 0; 3175 + } 3176 + 3143 3177 static const char * const an7583_xsi_rsts_names[] = { 3144 3178 "xsi-mac", 3145 3179 "hsi0-mac", ··· 3191 3181 return -EINVAL; 3192 3182 } 3193 3183 3184 + static u32 airoha_an7583_get_vip_port(struct airoha_gdm_port *port, int nbq) 3185 + { 3186 + switch (port->id) { 3187 + case AIROHA_GDM3_IDX: 3188 + if (!nbq) 3189 + return XSI_ETH_VIP_PORT_MASK; 3190 + break; 3191 + case AIROHA_GDM4_IDX: 3192 + if (!nbq) 3193 + return XSI_PCIE0_VIP_PORT_MASK; 3194 + if (nbq == 1) 3195 + return XSI_USB_VIP_PORT_MASK; 3196 + break; 3197 + default: 3198 + break; 3199 + } 3200 + 3201 + return 0; 3202 + } 3203 + 3194 3204 static const struct airoha_eth_soc_data en7581_soc_data = { 3195 3205 .version = 0x7581, 3196 3206 .xsi_rsts_names = en7581_xsi_rsts_names, ··· 3218 3188 .num_ppe = 2, 3219 3189 .ops = { 3220 3190 .get_src_port_id = airoha_en7581_get_src_port_id, 3191 + .get_vip_port = airoha_en7581_get_vip_port, 3221 3192 }, 3222 3193 }; 3223 3194 ··· 3229 3198 .num_ppe = 1, 3230 3199 .ops = { 3231 3200 .get_src_port_id = airoha_an7583_get_src_port_id, 3201 + .get_vip_port = airoha_an7583_get_vip_port, 3232 3202 }, 3233 3203 }; 3234 3204
+2
drivers/net/ethernet/airoha/airoha_eth.h
··· 536 536 struct airoha_qdma *qdma; 537 537 struct net_device *dev; 538 538 int id; 539 + int nbq; 539 540 540 541 struct airoha_hw_stats stats; 541 542 ··· 577 576 int num_ppe; 578 577 struct { 579 578 int (*get_src_port_id)(struct airoha_gdm_port *port, int nbq); 579 + u32 (*get_vip_port)(struct airoha_gdm_port *port, int nbq); 580 580 } ops; 581 581 }; 582 582