Skip to content

Commit 8cc72c6

Browse files
Lei WeiPaolo Abeni
authored andcommitted
net: ethernet: qualcomm: Initialize PPE L2 bridge settings
Initialize the L2 bridge settings for the PPE ports to only enable L2 frame forwarding between CPU port and PPE Ethernet ports. The per-port L2 bridge settings are initialized as follows: For PPE CPU port, the PPE bridge TX is enabled and FDB learning is disabled. For PPE physical ports, the default L2 forwarding action is initialized to forward to CPU port only. L2/FDB learning and forwarding will not be enabled for PPE physical ports yet, since the port's VSI (Virtual Switch Instance) and VSI membership are not yet configured, which are required for FDB forwarding. The VSI and FDB forwarding will later be enabled when switchdev is enabled. Signed-off-by: Lei Wei <[email protected]> Signed-off-by: Luo Jie <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent fa99608 commit 8cc72c6

File tree

2 files changed

+129
-1
lines changed

2 files changed

+129
-1
lines changed

drivers/net/ethernet/qualcomm/ppe/ppe_config.c

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1920,6 +1920,80 @@ static int ppe_queues_to_ring_init(struct ppe_device *ppe_dev)
19201920
return ppe_ring_queue_map_set(ppe_dev, 0, queue_bmap);
19211921
}
19221922

1923+
/* Initialize PPE bridge settings to only enable L2 frame receive and
1924+
* transmit between CPU port and PPE Ethernet ports.
1925+
*/
1926+
static int ppe_bridge_init(struct ppe_device *ppe_dev)
1927+
{
1928+
u32 reg, mask, port_cfg[4], vsi_cfg[2];
1929+
int ret, i;
1930+
1931+
/* Configure the following settings for CPU port0:
1932+
* a.) Enable Bridge TX
1933+
* b.) Disable FDB new address learning
1934+
* c.) Disable station move address learning
1935+
*/
1936+
mask = PPE_PORT_BRIDGE_TXMAC_EN;
1937+
mask |= PPE_PORT_BRIDGE_NEW_LRN_EN;
1938+
mask |= PPE_PORT_BRIDGE_STA_MOVE_LRN_EN;
1939+
ret = regmap_update_bits(ppe_dev->regmap,
1940+
PPE_PORT_BRIDGE_CTRL_ADDR,
1941+
mask,
1942+
PPE_PORT_BRIDGE_TXMAC_EN);
1943+
if (ret)
1944+
return ret;
1945+
1946+
for (i = 1; i < ppe_dev->num_ports; i++) {
1947+
/* Enable invalid VSI forwarding for all the physical ports
1948+
* to CPU port0, in case no VSI is assigned to the physical
1949+
* port.
1950+
*/
1951+
reg = PPE_L2_VP_PORT_TBL_ADDR + PPE_L2_VP_PORT_TBL_INC * i;
1952+
ret = regmap_bulk_read(ppe_dev->regmap, reg,
1953+
port_cfg, ARRAY_SIZE(port_cfg));
1954+
1955+
if (ret)
1956+
return ret;
1957+
1958+
PPE_L2_PORT_SET_INVALID_VSI_FWD_EN(port_cfg, true);
1959+
PPE_L2_PORT_SET_DST_INFO(port_cfg, 0);
1960+
1961+
ret = regmap_bulk_write(ppe_dev->regmap, reg,
1962+
port_cfg, ARRAY_SIZE(port_cfg));
1963+
if (ret)
1964+
return ret;
1965+
}
1966+
1967+
for (i = 0; i < PPE_VSI_TBL_ENTRIES; i++) {
1968+
/* Set the VSI forward membership to include only CPU port0.
1969+
* FDB learning and forwarding take place only after switchdev
1970+
* is supported later to create the VSI and join the physical
1971+
* ports to the VSI port member.
1972+
*/
1973+
reg = PPE_VSI_TBL_ADDR + PPE_VSI_TBL_INC * i;
1974+
ret = regmap_bulk_read(ppe_dev->regmap, reg,
1975+
vsi_cfg, ARRAY_SIZE(vsi_cfg));
1976+
if (ret)
1977+
return ret;
1978+
1979+
PPE_VSI_SET_MEMBER_PORT_BITMAP(vsi_cfg, BIT(0));
1980+
PPE_VSI_SET_UUC_BITMAP(vsi_cfg, BIT(0));
1981+
PPE_VSI_SET_UMC_BITMAP(vsi_cfg, BIT(0));
1982+
PPE_VSI_SET_BC_BITMAP(vsi_cfg, BIT(0));
1983+
PPE_VSI_SET_NEW_ADDR_LRN_EN(vsi_cfg, true);
1984+
PPE_VSI_SET_NEW_ADDR_FWD_CMD(vsi_cfg, PPE_ACTION_FORWARD);
1985+
PPE_VSI_SET_STATION_MOVE_LRN_EN(vsi_cfg, true);
1986+
PPE_VSI_SET_STATION_MOVE_FWD_CMD(vsi_cfg, PPE_ACTION_FORWARD);
1987+
1988+
ret = regmap_bulk_write(ppe_dev->regmap, reg,
1989+
vsi_cfg, ARRAY_SIZE(vsi_cfg));
1990+
if (ret)
1991+
return ret;
1992+
}
1993+
1994+
return 0;
1995+
}
1996+
19231997
int ppe_hw_config(struct ppe_device *ppe_dev)
19241998
{
19251999
int ret;
@@ -1952,5 +2026,9 @@ int ppe_hw_config(struct ppe_device *ppe_dev)
19522026
if (ret)
19532027
return ret;
19542028

1955-
return ppe_queues_to_ring_init(ppe_dev);
2029+
ret = ppe_queues_to_ring_init(ppe_dev);
2030+
if (ret)
2031+
return ret;
2032+
2033+
return ppe_bridge_init(ppe_dev);
19562034
}

drivers/net/ethernet/qualcomm/ppe/ppe_regs.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@
117117
#define PPE_EG_SERVICE_SET_TX_CNT_EN(tbl_cfg, value) \
118118
FIELD_MODIFY(PPE_EG_SERVICE_W1_TX_CNT_EN, (tbl_cfg) + 0x1, value)
119119

120+
/* PPE port bridge configuration */
121+
#define PPE_PORT_BRIDGE_CTRL_ADDR 0x60300
122+
#define PPE_PORT_BRIDGE_CTRL_ENTRIES 8
123+
#define PPE_PORT_BRIDGE_CTRL_INC 4
124+
#define PPE_PORT_BRIDGE_NEW_LRN_EN BIT(0)
125+
#define PPE_PORT_BRIDGE_STA_MOVE_LRN_EN BIT(3)
126+
#define PPE_PORT_BRIDGE_TXMAC_EN BIT(16)
127+
120128
/* PPE port control configurations for the traffic to the multicast queues. */
121129
#define PPE_MC_MTU_CTRL_TBL_ADDR 0x60a00
122130
#define PPE_MC_MTU_CTRL_TBL_ENTRIES 8
@@ -125,6 +133,36 @@
125133
#define PPE_MC_MTU_CTRL_TBL_MTU_CMD GENMASK(15, 14)
126134
#define PPE_MC_MTU_CTRL_TBL_TX_CNT_EN BIT(16)
127135

136+
/* PPE VSI configurations */
137+
#define PPE_VSI_TBL_ADDR 0x63800
138+
#define PPE_VSI_TBL_ENTRIES 64
139+
#define PPE_VSI_TBL_INC 0x10
140+
#define PPE_VSI_W0_MEMBER_PORT_BITMAP GENMASK(7, 0)
141+
#define PPE_VSI_W0_UUC_BITMAP GENMASK(15, 8)
142+
#define PPE_VSI_W0_UMC_BITMAP GENMASK(23, 16)
143+
#define PPE_VSI_W0_BC_BITMAP GENMASK(31, 24)
144+
#define PPE_VSI_W1_NEW_ADDR_LRN_EN BIT(0)
145+
#define PPE_VSI_W1_NEW_ADDR_FWD_CMD GENMASK(2, 1)
146+
#define PPE_VSI_W1_STATION_MOVE_LRN_EN BIT(3)
147+
#define PPE_VSI_W1_STATION_MOVE_FWD_CMD GENMASK(5, 4)
148+
149+
#define PPE_VSI_SET_MEMBER_PORT_BITMAP(tbl_cfg, value) \
150+
FIELD_MODIFY(PPE_VSI_W0_MEMBER_PORT_BITMAP, tbl_cfg, value)
151+
#define PPE_VSI_SET_UUC_BITMAP(tbl_cfg, value) \
152+
FIELD_MODIFY(PPE_VSI_W0_UUC_BITMAP, tbl_cfg, value)
153+
#define PPE_VSI_SET_UMC_BITMAP(tbl_cfg, value) \
154+
FIELD_MODIFY(PPE_VSI_W0_UMC_BITMAP, tbl_cfg, value)
155+
#define PPE_VSI_SET_BC_BITMAP(tbl_cfg, value) \
156+
FIELD_MODIFY(PPE_VSI_W0_BC_BITMAP, tbl_cfg, value)
157+
#define PPE_VSI_SET_NEW_ADDR_LRN_EN(tbl_cfg, value) \
158+
FIELD_MODIFY(PPE_VSI_W1_NEW_ADDR_LRN_EN, (tbl_cfg) + 0x1, value)
159+
#define PPE_VSI_SET_NEW_ADDR_FWD_CMD(tbl_cfg, value) \
160+
FIELD_MODIFY(PPE_VSI_W1_NEW_ADDR_FWD_CMD, (tbl_cfg) + 0x1, value)
161+
#define PPE_VSI_SET_STATION_MOVE_LRN_EN(tbl_cfg, value) \
162+
FIELD_MODIFY(PPE_VSI_W1_STATION_MOVE_LRN_EN, (tbl_cfg) + 0x1, value)
163+
#define PPE_VSI_SET_STATION_MOVE_FWD_CMD(tbl_cfg, value) \
164+
FIELD_MODIFY(PPE_VSI_W1_STATION_MOVE_FWD_CMD, (tbl_cfg) + 0x1, value)
165+
128166
/* PPE port control configurations for the traffic to the unicast queues. */
129167
#define PPE_MRU_MTU_CTRL_TBL_ADDR 0x65000
130168
#define PPE_MRU_MTU_CTRL_TBL_ENTRIES 256
@@ -163,6 +201,18 @@
163201
#define PPE_IN_L2_SERVICE_TBL_RX_CNT_EN BIT(30)
164202
#define PPE_IN_L2_SERVICE_TBL_TX_CNT_EN BIT(31)
165203

204+
/* L2 Port configurations */
205+
#define PPE_L2_VP_PORT_TBL_ADDR 0x98000
206+
#define PPE_L2_VP_PORT_TBL_ENTRIES 256
207+
#define PPE_L2_VP_PORT_TBL_INC 0x10
208+
#define PPE_L2_VP_PORT_W0_INVALID_VSI_FWD_EN BIT(0)
209+
#define PPE_L2_VP_PORT_W0_DST_INFO GENMASK(9, 2)
210+
211+
#define PPE_L2_PORT_SET_INVALID_VSI_FWD_EN(tbl_cfg, value) \
212+
FIELD_MODIFY(PPE_L2_VP_PORT_W0_INVALID_VSI_FWD_EN, tbl_cfg, value)
213+
#define PPE_L2_PORT_SET_DST_INFO(tbl_cfg, value) \
214+
FIELD_MODIFY(PPE_L2_VP_PORT_W0_DST_INFO, tbl_cfg, value)
215+
166216
/* PPE service code configuration for the tunnel packet. */
167217
#define PPE_TL_SERVICE_TBL_ADDR 0x306000
168218
#define PPE_TL_SERVICE_TBL_ENTRIES 256

0 commit comments

Comments
 (0)