From patchwork Wed Jan 10 11:40:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Luo X-Patchwork-Id: 13516079 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 972B3C4725D for ; Wed, 10 Jan 2024 11:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Gqmq+Ce90qjj9fdeCY8yabp84PHE1PgKnkaQxJVzTK4=; b=vzZsDX5E/AE1m2 /v3NexD4OotIz4QR4T3HeplUgEIQHCLuOaQMfyJydG4Z/Q5GH7L0t/oZ3el8R1z0AeooKSdKMdmUX LzXDbCKW5mbsb15xqxA2Nq2jfn8fTtl7q8LGMm5lUx31iZLtxoM4CWa2tIr7LvErtJEq1bWl5Q6Te iA7z83eMvKF8q/ZSO8F9ZOEx+o4BNsz0YJgf/0JB4AY6Ht4GRGYRkHQdRiD6IdALKOo3EXsh5fsz0 zRuA31Djp6wvcckB9Ku9vaR49DwQ2Hu8D2QzpOhctzYv4BJUO+WLccnDx82UF+0vxHZ15LchRO2Ii NaTYwYrf6ThDDqR9HaxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rNX0M-00BUVt-11; Wed, 10 Jan 2024 11:44:18 +0000 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rNX09-00BUO6-1k for linux-arm-kernel@lists.infradead.org; Wed, 10 Jan 2024 11:44:13 +0000 Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40A8eEdu022800; Wed, 10 Jan 2024 11:43:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=Qf2WPleeirlifByI4BG67UHUNLw0nveqotq4R5OSAUQ=; b=Wa Tr5Ati/Gin64tdO0CpimNPILY+hGqVYSGW3PzpGN49+xlIJAhbZ1BNIu+wvZXRXF iRlyLNe3tF5it/mDfSjhs/Z4vV/wIX8o8B2VEt8HFJ/KFvl18t0LCOH6Pqnf3gcf m3v0hPlyOhB5PRlbwNbDjRTY/q1VXeuioYZfh9yZRd+6Yb98tMUgpMlvrWhQW3QQ t+nJAcZRC+J337uyG6ZyWFeV3kdbtJoH2KbM5ckIhdrEv0U4pp68O04hnaIri7UJ HGZNamBzjN6qrMUxVPwK1B2EJPSwUmVaivldIOep0NMgP0SlDmb8AfInB4f/6dkO ww8zpH3hFsnEuhm9Y21A== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vh9vfj64r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Jan 2024 11:43:47 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 40ABhkOl008393 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Jan 2024 11:43:46 GMT Received: from akronite-sh-dev02.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Wed, 10 Jan 2024 03:43:36 -0800 From: Luo Jie To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , Subject: [PATCH net-next 16/20] net: ethernet: qualcomm: Add PPE L2 bridge initialization Date: Wed, 10 Jan 2024 19:40:28 +0800 Message-ID: <20240110114033.32575-17-quic_luoj@quicinc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240110114033.32575-1-quic_luoj@quicinc.com> References: <20240110114033.32575-1-quic_luoj@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: pXo3J6gbFD-h4LmHcYTH1GwRdbvRb1pk X-Proofpoint-ORIG-GUID: pXo3J6gbFD-h4LmHcYTH1GwRdbvRb1pk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_01,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 adultscore=0 bulkscore=0 mlxlogscore=942 spamscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2401100096 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240110_034405_605788_8E07FF52 X-CRM114-Status: GOOD ( 18.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Lei Wei Add PPE L2 bridge initialization. The default per-port settings are as follows: For PPE physical port, the L2 learning is enabled and the forward action is initialized to forward to CPU port. The PPE bridge tx is also enabled for PPE CPU port and disabled for PPE physical port. Signed-off-by: Lei Wei Signed-off-by: Luo Jie --- drivers/net/ethernet/qualcomm/ppe/ppe.c | 78 ++++++++++++++ drivers/net/ethernet/qualcomm/ppe/ppe.h | 10 ++ drivers/net/ethernet/qualcomm/ppe/ppe_regs.h | 102 +++++++++++++++++++ 3 files changed, 190 insertions(+) diff --git a/drivers/net/ethernet/qualcomm/ppe/ppe.c b/drivers/net/ethernet/qualcomm/ppe/ppe.c index 71973bce2cd2..04f80589c05b 100644 --- a/drivers/net/ethernet/qualcomm/ppe/ppe.c +++ b/drivers/net/ethernet/qualcomm/ppe/ppe.c @@ -1260,6 +1260,80 @@ static int ppe_rss_hash_init(struct ppe_device *ppe_dev) hash_cfg); } +static int ppe_bridge_init(struct ppe_device *ppe_dev) +{ + union ppe_l2_vp_port_tbl_u port_tbl; + union ppe_vsi_tbl_u vsi_tbl; + u32 reg_val = 0; + int i = 0; + + /* CPU port0 initialization */ + reg_val = FIELD_PREP(PPE_PORT_BRIDGE_CTRL_ISOLATION_BITMAP, 0x7F) | + PPE_PORT_BRIDGE_CTRL_PROMISC_EN; + ppe_mask(ppe_dev, + PPE_PORT_BRIDGE_CTRL + PPE_PORT_BRIDGE_CTRL_INC * PPE_PORT0, + PPE_PORT_BRIDGE_CTRL_MASK, + reg_val | PPE_PORT_BRIDGE_CTRL_TXMAC_EN); + + /* Physical and virtual physical port initialization */ + reg_val |= (PPE_PORT_BRIDGE_CTRL_STATION_MODE_LRN_EN | + PPE_PORT_BRIDGE_CTRL_NEW_ADDR_LRN_EN); + for (i = PPE_PORT1; i <= PPE_PORT6; i++) { + ppe_mask(ppe_dev, + PPE_PORT_BRIDGE_CTRL + PPE_PORT_BRIDGE_CTRL_INC * i, + PPE_PORT_BRIDGE_CTRL_MASK, + reg_val); + + /* Invalid vsi fowarding to CPU port0 */ + memset(&port_tbl, 0, sizeof(port_tbl)); + ppe_read_tbl(ppe_dev, + PPE_L2_VP_PORT_TBL + PPE_L2_VP_PORT_TBL_INC * i, + port_tbl.val, + sizeof(port_tbl.val)); + port_tbl.bf.invalid_vsi_forwarding_en = true; + port_tbl.bf.dst_info = PPE_PORT0; + ppe_write_tbl(ppe_dev, + PPE_L2_VP_PORT_TBL + PPE_L2_VP_PORT_TBL_INC * i, + port_tbl.val, + sizeof(port_tbl.val)); + } + + /* Internal port7 initialization */ + ppe_mask(ppe_dev, + PPE_PORT_BRIDGE_CTRL + PPE_PORT_BRIDGE_CTRL_INC * PPE_PORT7, + PPE_PORT_BRIDGE_CTRL_MASK, + reg_val | PPE_PORT_BRIDGE_CTRL_TXMAC_EN); + + /* Enable Global L2 Learn and Ageing */ + ppe_mask(ppe_dev, + PPE_L2_GLOBAL_CONFIG, + PPE_L2_GLOBAL_CONFIG_LRN_EN | PPE_L2_GLOBAL_CONFIG_AGE_EN, + PPE_L2_GLOBAL_CONFIG_LRN_EN | PPE_L2_GLOBAL_CONFIG_AGE_EN); + + /* Vsi initialization */ + for (i = 0; i < PPE_VSI_TBL_NUM; i++) { + memset(&vsi_tbl, 0, sizeof(vsi_tbl)); + ppe_read_tbl(ppe_dev, + PPE_VSI_TBL + PPE_VSI_TBL_INC * i, + vsi_tbl.val, + sizeof(vsi_tbl.val)); + vsi_tbl.bf.member_port_bitmap = BIT(PPE_PORT0); + vsi_tbl.bf.uuc_bitmap = BIT(PPE_PORT0); + vsi_tbl.bf.umc_bitmap = BIT(PPE_PORT0); + vsi_tbl.bf.bc_bitmap = BIT(PPE_PORT0); + vsi_tbl.bf.new_addr_lrn_en = true; + vsi_tbl.bf.new_addr_fwd_cmd = 0; + vsi_tbl.bf.station_move_lrn_en = true; + vsi_tbl.bf.station_move_fwd_cmd = 0; + ppe_write_tbl(ppe_dev, + PPE_VSI_TBL + PPE_VSI_TBL_INC * i, + vsi_tbl.val, + sizeof(vsi_tbl.val)); + } + + return 0; +} + static int ppe_dev_hw_init(struct ppe_device *ppe_dev) { int ret; @@ -1276,6 +1350,10 @@ static int ppe_dev_hw_init(struct ppe_device *ppe_dev) if (ret) return ret; + ret = ppe_bridge_init(ppe_dev); + if (ret) + return ret; + return ppe_rss_hash_init(ppe_dev); } diff --git a/drivers/net/ethernet/qualcomm/ppe/ppe.h b/drivers/net/ethernet/qualcomm/ppe/ppe.h index 507626b6ab2e..828d467540c9 100644 --- a/drivers/net/ethernet/qualcomm/ppe/ppe.h +++ b/drivers/net/ethernet/qualcomm/ppe/ppe.h @@ -11,6 +11,16 @@ #include #include +/* PPE Ports */ +#define PPE_PORT0 0 +#define PPE_PORT1 1 +#define PPE_PORT2 2 +#define PPE_PORT3 3 +#define PPE_PORT4 4 +#define PPE_PORT5 5 +#define PPE_PORT6 6 +#define PPE_PORT7 7 + enum ppe_clk_id { /* clocks for CMN PLL */ PPE_CMN_AHB_CLK, diff --git a/drivers/net/ethernet/qualcomm/ppe/ppe_regs.h b/drivers/net/ethernet/qualcomm/ppe/ppe_regs.h index 98bf19f974ce..13115405bad9 100644 --- a/drivers/net/ethernet/qualcomm/ppe/ppe_regs.h +++ b/drivers/net/ethernet/qualcomm/ppe/ppe_regs.h @@ -238,6 +238,39 @@ union ppe_eg_service_cfg_u { #define PPE_TX_BUFF_THRSH_XOFF GENMASK(7, 0) #define PPE_TX_BUFF_THRSH_XON GENMASK(15, 8) +#define PPE_L2_GLOBAL_CONFIG 0x60038 +#define PPE_L2_GLOBAL_CONFIG_LRN_EN BIT(6) +#define PPE_L2_GLOBAL_CONFIG_AGE_EN BIT(7) + +#define PPE_MIRROR_ANALYZER 0x60040 +#define PPE_MIRROR_ANALYZER_NUM 1 +#define PPE_MIRROR_ANALYZER_INC 4 +#define PPE_MIRROR_ANALYZER_INGRESS_PORT GENMASK(5, 0) +#define PPE_MIRROR_ANALYZER_EGRESS_PORT GENMASK(13, 8) + +#define PPE_PORT_BRIDGE_CTRL 0x60300 +#define PPE_PORT_BRIDGE_CTRL_NUM 8 +#define PPE_PORT_BRIDGE_CTRL_INC 4 +#define PPE_PORT_BRIDGE_CTRL_NEW_ADDR_LRN_EN BIT(0) +#define PPE_PORT_BRIDGE_CTRL_NEW_ADDR_FWD_CMD GENMASK(2, 1) +#define PPE_PORT_BRIDGE_CTRL_STATION_MODE_LRN_EN BIT(3) +#define PPE_PORT_BRIDGE_CTRL_STATION_MODE_FWD_CMD GENMASK(5, 4) +#define PPE_PORT_BRIDGE_CTRL_ISOLATION_BITMAP GENMASK(15, 8) +#define PPE_PORT_BRIDGE_CTRL_TXMAC_EN BIT(16) +#define PPE_PORT_BRIDGE_CTRL_PROMISC_EN BIT(17) +#define PPE_PORT_BRIDGE_CTRL_MASK GENMASK(17, 0) + +#define PPE_PORT_MIRROR 0x60800 +#define PPE_PORT_MIRROR_NUM 8 +#define PPE_PORT_MIRROR_INC 4 +#define PPE_PORT_MIRROR_INGRESS_EN BIT(0) +#define PPE_PORT_MIRROR_EGRESS_EN BIT(1) + +#define PPE_CST_STATE 0x60100 +#define PPE_CST_STATE_NUM 8 +#define PPE_CST_STATE_INC 4 +#define PPE_CST_STATE_PORT_STATE GENMASK(1, 0) + #define PPE_MC_MTU_CTRL_TBL 0x60a00 #define PPE_MC_MTU_CTRL_TBL_NUM 8 #define PPE_MC_MTU_CTRL_TBL_INC 4 @@ -245,6 +278,28 @@ union ppe_eg_service_cfg_u { #define PPE_MC_MTU_CTRL_TBL_MTU_CMD GENMASK(15, 14) #define PPE_MC_MTU_CTRL_TBL_TX_CNT_EN BIT(16) +#define PPE_VSI_TBL 0x63800 +#define PPE_VSI_TBL_NUM 64 +#define PPE_VSI_TBL_INC 0x10 + +/* PPE vsi configurations */ +struct ppe_vsi_tbl { + u32 member_port_bitmap:8, + uuc_bitmap:8, + umc_bitmap:8, + bc_bitmap:8; + u32 new_addr_lrn_en:1, + new_addr_fwd_cmd:2, + station_move_lrn_en:1, + station_move_fwd_cmd:2, + res0:26; +}; + +union ppe_vsi_tbl_u { + u32 val[2]; + struct ppe_vsi_tbl bf; +}; + #define PPE_MRU_MTU_CTRL_TBL 0x65000 #define PPE_MRU_MTU_CTRL_TBL_NUM 256 #define PPE_MRU_MTU_CTRL_TBL_INC 0x10 @@ -295,6 +350,53 @@ union ppe_mru_mtu_ctrl_cfg_u { #define PPE_IN_L2_SERVICE_TBL_RX_CNT_EN BIT(30) #define PPE_IN_L2_SERVICE_TBL_TX_CNT_EN BIT(31) +#define PPE_L2_VP_PORT_TBL 0x98000 +#define PPE_L2_VP_PORT_TBL_NUM 256 +#define PPE_L2_VP_PORT_TBL_INC 0x10 + +/* Port configurations */ +struct ppe_l2_vp_port_tbl { + u32 invalid_vsi_forwarding_en:1, + promisc_en:1, + dst_info:8, + physical_port:3, + new_addr_lrn_en:1, + new_addr_fwd_cmd:2, + station_move_lrn_en:1, + station_move_fwd_cmd:2, + lrn_lmt_cnt:12, + lrn_lmt_en:1; + u32 lrn_lmt_exceed_fwd:2, + eg_vlan_fltr_cmd:1, + port_isolation_bitmap:8, + isol_profile:6, + isol_en:1, + policer_en:1, + policer_index:9, + vp_state_check_en:1, + vp_type:1, + vp_context_active:1, + vp_eg_data_valid:1; + u32 physical_port_mtu_check_en:1, + mtu_check_type:1, + extra_header_len:8, + eg_vlan_fmt_valid:1, + eg_stag_fmt:1, + eg_ctag_fmt:1, + exception_fmt_ctrl:1, + enq_service_code_en:1, + enq_service_code:8, + enq_phy_port:3, + app_ctrl_profile_0:6; + u32 app_ctrl_profile_1:2, + res0:30; +}; + +union ppe_l2_vp_port_tbl_u { + u32 val[4]; + struct ppe_l2_vp_port_tbl bf; +}; + #define PPE_PORT_RX_CNT_TBL 0x150000 #define PPE_PORT_RX_CNT_TBL_NUM 256 #define PPE_PORT_RX_CNT_TBL_INC 0x20