From patchwork Tue Oct 23 02:26:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tristram.Ha@microchip.com X-Patchwork-Id: 987990 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=microchip.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42fHM45Zjcz9sN6 for ; Tue, 23 Oct 2018 13:26:24 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727160AbeJWKrb (ORCPT ); Tue, 23 Oct 2018 06:47:31 -0400 Received: from esa3.microchip.iphmx.com ([68.232.153.233]:63304 "EHLO esa3.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727044AbeJWKrb (ORCPT ); Tue, 23 Oct 2018 06:47:31 -0400 X-IronPort-AV: E=Sophos;i="5.54,414,1534834800"; d="scan'208";a="22103812" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 22 Oct 2018 19:26:17 -0700 Received: from localhost.localdomain (10.10.76.4) by chn-sv-exch05.mchp-main.com (10.10.76.106) with Microsoft SMTP Server id 14.3.352.0; Mon, 22 Oct 2018 19:26:16 -0700 From: To: Andrew Lunn , Florian Fainelli , Pavel Machek CC: Tristram Ha , Ruediger Schmitt , , Subject: [PATCH v3 net-next 00/11] net: dsa: microchip: Modify KSZ9477 DSA driver in preparation to add other KSZ switch drivers Date: Mon, 22 Oct 2018 19:26:04 -0700 Message-ID: <1540261575-1889-1-git-send-email-Tristram.Ha@microchip.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Tristram Ha This series of patches is to modify the original KSZ9477 DSA driver so that other KSZ switch drivers can be added and use the common code. There are several steps to accomplish this achievement. First is to rename some function names with a prefix to indicate chip specific function. Second is to move common code into header that can be shared. Last is to modify tag_ksz.c so that it can handle many tail tag formats used by different KSZ switch drivers. ksz_common.c will contain the common code used by all KSZ switch drivers. ksz9477.c will contain KSZ9477 code from the original ksz_common.c. ksz9477_spi.c is renamed from ksz_spi.c. ksz9477_reg.h is renamed from ksz_9477_reg.h. ksz_common.h is added to provide common code access to KSZ switch drivers. ksz_spi.h is added to provide common SPI access functions to KSZ SPI drivers. v3 - The phy_device structure is used to hold port link information - A structure is passed in ksz_xmit and ksz_rcv instead of function pointer - Switch offload forwarding is supported v2 - Initialize reg_mutex before use - The alu_mutex is only used inside chip specific functions v1 - Each patch in the set is self-contained - Use ksz9477 prefix to indicate KSZ9477 specific code Tristram Ha (11): Replace license with GPL. Clean up code according to patch check suggestions. Initialize mutex before use. Rename some functions with ksz9477 prefix to separate chip specific code from common code. Rename ksz_spi.c to ksz9477_spi.c and update Kconfig in preparation to add more KSZ switch drivers. Break KSZ9477 DSA driver into two files in preparation to add more KSZ switch drivers. Add common functions in ksz_common.h so that other KSZ switch drivers can access code in ksz_common.c. Add ksz_spi.h for common functions used by KSZ switch SPI drivers. Prepare PHY for proper advertisement and get link status for the port. Rename ksz_9477_reg.h to ksz9477_reg.h for consistency as the product name is always KSZ####. Add MIB counter reading support. Modify tag_ksz.c so that tail tag code can be used by other KSZ switch drivers. Add switch offload forwarding support. drivers/net/dsa/microchip/Kconfig | 18 +- drivers/net/dsa/microchip/Makefile | 5 +- drivers/net/dsa/microchip/ksz9477.c | 1387 ++++++++++++++++++++ .../microchip/{ksz_9477_reg.h => ksz9477_reg.h} | 23 +- drivers/net/dsa/microchip/ksz9477_spi.c | 189 +++ drivers/net/dsa/microchip/ksz_common.c | 1253 ++++-------------- drivers/net/dsa/microchip/ksz_common.h | 231 ++++ drivers/net/dsa/microchip/ksz_priv.h | 256 ++-- drivers/net/dsa/microchip/ksz_spi.c | 217 --- drivers/net/dsa/microchip/ksz_spi.h | 82 ++ include/net/dsa.h | 2 +- net/dsa/Kconfig | 4 + net/dsa/dsa.c | 8 +- net/dsa/dsa_priv.h | 2 +- net/dsa/tag_ksz.c | 101 +- 15 files changed, 2354 insertions(+), 1424 deletions(-) create mode 100644 drivers/net/dsa/microchip/ksz9477.c rename drivers/net/dsa/microchip/{ksz_9477_reg.h => ksz9477_reg.h} (98%) create mode 100644 drivers/net/dsa/microchip/ksz9477_spi.c create mode 100644 drivers/net/dsa/microchip/ksz_common.h delete mode 100644 drivers/net/dsa/microchip/ksz_spi.c create mode 100644 drivers/net/dsa/microchip/ksz_spi.h