From patchwork Thu Mar 13 06:56:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungho An X-Patchwork-Id: 26180 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f197.google.com (mail-yk0-f197.google.com [209.85.160.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 62466203AC for ; Thu, 13 Mar 2014 06:56:39 +0000 (UTC) Received: by mail-yk0-f197.google.com with SMTP id 19sf3330107ykq.0 for ; Wed, 12 Mar 2014 23:56:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:thread-index:dlp-filter:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding:content-language; bh=zTPZTJUY7auyuzpH/7fqbSow1L/DeVf6OtmRIk1w6Z0=; b=D8SLZlhZIEIpL0Ea80ynEfRbaFUEKhB24CG3YRsrOzkie/6qb5417YlXFQLGJtcgJA yMwnkq13mLbDwKphNY5iY4iREn81sty++8UqzOAtT/pZVAnMKmlIBZ59MGWyswFc26rd +MjeqHSNdR9GLmlFicYvr1fVN8drc6oAtJtDZJxa1QtePt1QCGLOAck2YGl8dIc/DAf6 GQskzR7a1Z8GsR/9KwL5c06RD44hweuAE3xBgImmWuRhuVfTviHLN/f/coxl+PadZKY/ 181zjRdfyUk2bZuRjvDf/dz7xQamuKMMH3g9GRGr3GAjB1ka2C/F1cm8G1osnWVulQnk ceEA== X-Gm-Message-State: ALoCoQnE6VvWpHFpg24SOylkoF31cYF4CBPOFBngmf05WuW0mdzp2USghGzpAnynlZJgqAGAAMi7 X-Received: by 10.236.90.116 with SMTP id d80mr89129yhf.16.1394693799151; Wed, 12 Mar 2014 23:56:39 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.37.102 with SMTP id q93ls171885qgq.67.gmail; Wed, 12 Mar 2014 23:56:39 -0700 (PDT) X-Received: by 10.220.131.210 with SMTP id y18mr105638vcs.12.1394693799055; Wed, 12 Mar 2014 23:56:39 -0700 (PDT) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id g4si452112vch.148.2014.03.12.23.56.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Mar 2014 23:56:39 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id jw12so611590veb.41 for ; Wed, 12 Mar 2014 23:56:39 -0700 (PDT) X-Received: by 10.52.12.36 with SMTP id v4mr87526vdb.20.1394693798952; Wed, 12 Mar 2014 23:56:38 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp345608vck; Wed, 12 Mar 2014 23:56:38 -0700 (PDT) X-Received: by 10.66.146.105 with SMTP id tb9mr136149pab.157.1394693797942; Wed, 12 Mar 2014 23:56:37 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gj8si1286416pbc.24.2014.03.12.23.56.37; Wed, 12 Mar 2014 23:56:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753219AbaCMG4X (ORCPT + 4 others); Thu, 13 Mar 2014 02:56:23 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:44209 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753153AbaCMG4R (ORCPT ); Thu, 13 Mar 2014 02:56:17 -0400 Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N2D00IWB4LRQ0B0@mailout3.samsung.com>; Thu, 13 Mar 2014 15:56:15 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.51]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id 9A.37.10364.F8651235; Thu, 13 Mar 2014 15:56:15 +0900 (KST) X-AuditID: cbfee690-b7f266d00000287c-7c-5321568f7e94 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 1A.85.29263.F8651235; Thu, 13 Mar 2014 15:56:15 +0900 (KST) Received: from DObh74an01 ([12.36.166.149]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N2D00JBC4LRHP50@mmp2.samsung.com>; Thu, 13 Mar 2014 15:56:15 +0900 (KST) From: Byungho An To: netdev@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: davem@davemloft.net, ilho215.lee@samsung.com, vipul.pandya@samsung.com, 'Joe Perches' Subject: [PATCH V2 RE-SEND 6/7] net: sxgbe: add ethtool related functions support Samsung sxgbe Date: Thu, 13 Mar 2014 15:56:15 +0900 Message-id: <007f01cf3e89$53bfe3c0$fb3fab40$%an@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac8+iVOjOQn8VlSAQ9KtOGa01D2AZg== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFIsWRmVeSWpSXmKPExsVy+t8zY93+MMVgg/1dBhZXzx1jtJhzvoXF 4ui/hYwWs+8/ZrHoXXCVzWLG+X1MFscWiFlsW3CB2YHDY8vKm0weX1ZdY/bo27KK0ePzJrkA ligum5TUnMyy1CJ9uwSujGnLDzMVzF3IWLH89WrWBsaVrYxdjJwcEgImEl0z/7BB2GISF+6t B7K5OIQEljFKvN67kgWm6MuzfSwQielAic9drBDOb0aJbVvfs4NUsQmoSTTPvAw2SkTAVmLJ kc9gcWaBXIk/yzYzg9jCAokSG28tAKthEVCVWDn5G9AgDg5eARuJo1dUQcK8AoISPybfY4Fo 1ZJYv/M4E4QtL7F5zVtmkHIJAXWJR391ITbpSXxcdx5qk4jEvhfvGEFOkxC4xi7x5/kBRohV AhLfJh9igeiVldh0gBniL0mJgytusExgFJuFZPMsJJtnIdk8C8mKBYwsqxhFUwuSC4qT0otM 9IoTc4tL89L1kvNzNzFC4nHCDsZ7B6wPMSYDrZ/ILCWanA+M57ySeENjMyMLUxNTYyNzSzPS hJXEedUeJQUJCaQnlqRmp6YWpBbFF5XmpBYfYmTi4JRqYNQ0tKz8lN97Zn9vzL5XFqIl3oGf b0dcYc+6anPabcLrfoZt3ZLLhXalO9p5ORn+8nrZletX1/Mu91d8m2+vltnXNxNmWywv2XOw U1xmxZ5Jlzrr581XMnaQXyrm/OH3MpfCqO5Q3hWWJ435n/48FWGezDZlq83ijdnv1Ep3Vk/4 2PJ6UfW5GiWW4oxEQy3mouJEAEuk0vHdAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOKsWRmVeSWpSXmKPExsVy+t9jQd3+MMVgg9tv1S2unjvGaDHnfAuL xdF/CxktZt9/zGLRu+Aqm8WM8/uYLI4tELPYtuACswOHx5aVN5k8vqy6xuzRt2UVo8fnTXIB LFENjDYZqYkpqUUKqXnJ+SmZeem2St7B8c7xpmYGhrqGlhbmSgp5ibmptkouPgG6bpk5QGco KZQl5pQChQISi4uV9O0wTQgNcdO1gGmM0PUNCYLrMTJAAwnrGDOmLT/MVDB3IWPF8terWRsY V7YydjFyckgImEh8ebaPBcIWk7hwbz1bFyMXh5DAdEaJ15+7WCGc34wS27a+ZwepYhNQk2ie eZkNxBYRsJVYcuQzWJxZIFfiz7LNzCC2sECixMZbC8BqWARUJVZO/gY0iIODV8BG4ugVVZAw r4CgxI/J91ggWrUk1u88zgRhy0tsXvOWGaRcQkBd4tFfXYhNehIf152H2iQise/FO8YJjAKz kEyahWTSLCSTZiFpWcDIsopRNLUguaA4KT3XUK84Mbe4NC9dLzk/dxMjONqfSe1gXNlgcYhR gINRiYd3xXKFYCHWxLLiytxDjBIczEoivJ4+isFCvCmJlVWpRfnxRaU5qcWHGJOB/pzILCWa nA9MRHkl8YbGJmZGlkZmFkYm5uakCSuJ8x5otQ4UEkhPLEnNTk0tSC2C2cLEwSnVwCgy9etn m3bWmLhe/gTH2ObAE0Vqf7/f9wj7c9rirgw/l0DXi7K9N+UkXb5cv3H/l8JfvUXnE0Mf22mm nfzlefziwU3sfn3vT3/NaPp+8dr3p/yZXXu2h7DE39jwr7lGj+WGwSo1jVJX/j4e88fW8812 XjR7u1oul2P3DKkHJdWz809LXb+eKKvEUpyRaKjFXFScCAA9UO3QOgMAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: netdev@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: bh74.an@samsung.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit Content-language: ko From: Vipul Pandya This patch adds ethtool related functions. Signed-off-by: Vipul Pandya Neatening-by: Joe Perches Signed-off-by: Byungho An --- drivers/net/ethernet/samsung/sxgbe_common.h | 28 +- drivers/net/ethernet/samsung/sxgbe_ethtool.c | 509 +++++++++++++++++++++++++- drivers/net/ethernet/samsung/sxgbe_main.c | 14 +- drivers/net/ethernet/samsung/sxgbe_reg.h | 6 + 4 files changed, 538 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/samsung/sxgbe_common.h b/drivers/net/ethernet/samsung/sxgbe_common.h index b029181..1f65194 100644 --- a/drivers/net/ethernet/samsung/sxgbe_common.h +++ b/drivers/net/ethernet/samsung/sxgbe_common.h @@ -42,8 +42,12 @@ struct sxgbe_mtl_ops; #define SXGBE_RX_QUEUES 16 /* Max/Min RI Watchdog Timer count value */ -#define SXGBE_MAX_DMA_RIWT 0xff -#define SXGBE_MIN_DMA_RIWT 0x20 +/* Calculated based how much time does it take to fill 256KB Rx memory + * at 10Gb speed at 156MHz clock rate and considered little less then + * the actual value. + */ +#define SXGBE_MAX_DMA_RIWT 0x70 +#define SXGBE_MIN_DMA_RIWT 0x01 /* Tx coalesce parameters */ #define SXGBE_COAL_TX_TIMER 40000 @@ -203,6 +207,20 @@ enum dma_irq_status { #define SXGBE_FOR_EACH_QUEUE(max_queues, queue_num) \ for (queue_num = 0; queue_num < max_queues; queue_num++) +#define DRV_VERSION "1.0.0" + +#define SXGBE_MAX_RX_CHANNELS 16 +#define SXGBE_MAX_TX_CHANNELS 16 + +#define START_MAC_REG_OFFSET 0x0000 +#define MAX_MAC_REG_OFFSET 0x0DFC +#define START_MTL_REG_OFFSET 0x1000 +#define MAX_MTL_REG_OFFSET 0x18FC +#define START_DMA_REG_OFFSET 0x3000 +#define MAX_DMA_REG_OFFSET 0x38FC + +#define REG_SPACE_SIZE 0x2000 + /* sxgbe statistics counters */ struct sxgbe_extra_stats { /* TX/RX IRQ events */ @@ -484,7 +502,8 @@ struct sxgbe_priv_data { int oldlink; int speed; int oldduplex; - unsigned int flow_ctrl; + u8 rx_pause; + u8 tx_pause; unsigned int pause; struct mii_bus *mii; int mii_irq[PHY_MAX_ADDR]; @@ -504,6 +523,7 @@ struct sxgbe_priv_data { u32 adv_ts; int use_riwt; spinlock_t ptp_lock; + struct ptp_clock *ptp_clock; /* EEE-LPI specific members */ struct timer_list eee_ctrl_timer; @@ -542,4 +562,6 @@ const struct sxgbe_mtl_ops *sxgbe_get_mtl_ops(void); void sxgbe_disable_eee_mode(struct sxgbe_priv_data * const priv); bool sxgbe_eee_init(struct sxgbe_priv_data * const priv); +int sxgbe_set_flow_ctrl(struct sxgbe_priv_data *priv, int rx, int tx); + #endif /* __SXGBE_COMMON_H__ */ diff --git a/drivers/net/ethernet/samsung/sxgbe_ethtool.c b/drivers/net/ethernet/samsung/sxgbe_ethtool.c index 89b1450..6a16f05 100644 --- a/drivers/net/ethernet/samsung/sxgbe_ethtool.c +++ b/drivers/net/ethernet/samsung/sxgbe_ethtool.c @@ -12,12 +12,17 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include +#include #include +#include #include "sxgbe_common.h" +#include "sxgbe_reg.h" +#include "sxgbe_dma.h" struct sxgbe_stats { char stat_string[ETH_GSTRING_LEN]; @@ -33,17 +38,106 @@ struct sxgbe_stats { } static const struct sxgbe_stats sxgbe_gstrings_stats[] = { + /* TX/RX IRQ events */ + SXGBE_STAT(tx_process_stopped_irq), + SXGBE_STAT(tx_ctxt_desc_err), + SXGBE_STAT(tx_threshold), + SXGBE_STAT(rx_threshold), + SXGBE_STAT(tx_pkt_n), + SXGBE_STAT(rx_pkt_n), + SXGBE_STAT(normal_irq_n), + SXGBE_STAT(tx_normal_irq_n), + SXGBE_STAT(rx_normal_irq_n), + SXGBE_STAT(napi_poll), + SXGBE_STAT(tx_clean), + SXGBE_STAT(tx_reset_ic_bit), + SXGBE_STAT(rx_process_stopped_irq), + SXGBE_STAT(rx_underflow_irq), + + /* Bus access errors */ + SXGBE_STAT(fatal_bus_error_irq), + SXGBE_STAT(tx_read_transfer_err), + SXGBE_STAT(tx_write_transfer_err), + SXGBE_STAT(tx_desc_access_err), + SXGBE_STAT(tx_buffer_access_err), + SXGBE_STAT(tx_data_transfer_err), + SXGBE_STAT(rx_read_transfer_err), + SXGBE_STAT(rx_write_transfer_err), + SXGBE_STAT(rx_desc_access_err), + SXGBE_STAT(rx_buffer_access_err), + SXGBE_STAT(rx_data_transfer_err), + SXGBE_STAT(pmt_irq_event_n), + + /* EEE-LPI stats */ SXGBE_STAT(tx_lpi_entry_n), SXGBE_STAT(tx_lpi_exit_n), SXGBE_STAT(rx_lpi_entry_n), SXGBE_STAT(rx_lpi_exit_n), SXGBE_STAT(eee_wakeup_error_n), - SXGBE_STAT(pmt_irq_event_n), + + /* RX specific */ + /* L2 error */ + SXGBE_STAT(rx_code_gmii_err), + SXGBE_STAT(rx_watchdog_err), + SXGBE_STAT(rx_crc_err), + SXGBE_STAT(rx_gaint_pkt_err), + SXGBE_STAT(ip_hdr_err), + SXGBE_STAT(ip_payload_err), + SXGBE_STAT(overflow_error), + + /* L2 Pkt type */ + SXGBE_STAT(len_pkt), + SXGBE_STAT(mac_ctl_pkt), + SXGBE_STAT(dcb_ctl_pkt), + SXGBE_STAT(arp_pkt), + SXGBE_STAT(oam_pkt), + SXGBE_STAT(untag_okt), + SXGBE_STAT(other_pkt), + SXGBE_STAT(svlan_tag_pkt), + SXGBE_STAT(cvlan_tag_pkt), + SXGBE_STAT(dvlan_ocvlan_icvlan_pkt), + SXGBE_STAT(dvlan_osvlan_isvlan_pkt), + SXGBE_STAT(dvlan_osvlan_icvlan_pkt), + SXGBE_STAT(dvan_ocvlan_icvlan_pkt), + + /* L3/L4 Pkt type */ + SXGBE_STAT(not_ip_pkt), + SXGBE_STAT(ip4_tcp_pkt), + SXGBE_STAT(ip4_udp_pkt), + SXGBE_STAT(ip4_icmp_pkt), + SXGBE_STAT(ip4_unknown_pkt), + SXGBE_STAT(ip6_tcp_pkt), + SXGBE_STAT(ip6_udp_pkt), + SXGBE_STAT(ip6_icmp_pkt), + SXGBE_STAT(ip6_unknown_pkt), + + /* Filter specific */ + SXGBE_STAT(vlan_filter_match), + SXGBE_STAT(sa_filter_fail), + SXGBE_STAT(da_filter_fail), + SXGBE_STAT(hash_filter_pass), + SXGBE_STAT(l3_filter_match), + SXGBE_STAT(l4_filter_match), + + /* RX context specific */ + SXGBE_STAT(timestamp_dropped), + SXGBE_STAT(rx_msg_type_no_ptp), + SXGBE_STAT(rx_ptp_type_sync), + SXGBE_STAT(rx_ptp_type_follow_up), + SXGBE_STAT(rx_ptp_type_delay_req), + SXGBE_STAT(rx_ptp_type_delay_resp), + SXGBE_STAT(rx_ptp_type_pdelay_req), + SXGBE_STAT(rx_ptp_type_pdelay_resp), + SXGBE_STAT(rx_ptp_type_pdelay_follow_up), + SXGBE_STAT(rx_ptp_announce), + SXGBE_STAT(rx_ptp_mgmt), + SXGBE_STAT(rx_ptp_signal), + SXGBE_STAT(rx_ptp_resv_msg_type), }; #define SXGBE_STATS_LEN ARRAY_SIZE(sxgbe_gstrings_stats) -static int sxgbe_ethtool_get_eee(struct net_device *dev, - struct ethtool_eee *edata) +static int sxgbe_get_eee(struct net_device *dev, + struct ethtool_eee *edata) { struct sxgbe_priv_data *priv = netdev_priv(dev); @@ -57,8 +151,8 @@ static int sxgbe_ethtool_get_eee(struct net_device *dev, return phy_ethtool_get_eee(priv->phydev, edata); } -static int sxgbe_ethtool_set_eee(struct net_device *dev, - struct ethtool_eee *edata) +static int sxgbe_set_eee(struct net_device *dev, + struct ethtool_eee *edata) { struct sxgbe_priv_data *priv = netdev_priv(dev); @@ -125,9 +219,410 @@ static int sxgbe_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) return 0; } +static void sxgbe_getdrvinfo(struct net_device *dev, + struct ethtool_drvinfo *info) +{ + strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); +} + +static int sxgbe_getsettings(struct net_device *dev, + struct ethtool_cmd *cmd) +{ + struct sxgbe_priv_data *priv = netdev_priv(dev); + + if (priv->phydev) + return phy_ethtool_gset(priv->phydev, cmd); + + return -ENODEV; +} + +static int sxgbe_setsettings(struct net_device *dev, struct ethtool_cmd *cmd) +{ + struct sxgbe_priv_data *priv = netdev_priv(dev); + + if (priv->phydev) + return phy_ethtool_sset(priv->phydev, cmd); + + return -ENODEV; +} + +static u32 sxgbe_getmsglevel(struct net_device *dev) +{ + struct sxgbe_priv_data *priv = netdev_priv(dev); + return priv->msg_enable; +} + +static void sxgbe_setmsglevel(struct net_device *dev, u32 level) +{ + struct sxgbe_priv_data *priv = netdev_priv(dev); + priv->msg_enable = level; +} + +static int sxgbe_get_ts_info(struct net_device *dev, + struct ethtool_ts_info *info) +{ + struct sxgbe_priv_data *priv = netdev_priv(dev); + + if (!priv->hw_cap.atime_stamp) + return ethtool_op_get_ts_info(dev, info); + + info->so_timestamping = (SOF_TIMESTAMPING_TX_SOFTWARE | + SOF_TIMESTAMPING_RX_SOFTWARE | + SOF_TIMESTAMPING_SOFTWARE | + SOF_TIMESTAMPING_TX_HARDWARE | + SOF_TIMESTAMPING_RX_HARDWARE | + SOF_TIMESTAMPING_RAW_HARDWARE); + + if (priv->ptp_clock) + info->phc_index = ptp_clock_index(priv->ptp_clock); + + info->tx_types = ((1 << HWTSTAMP_TX_OFF) | + (1 << HWTSTAMP_TX_ON) | + (1 << HWTSTAMP_TX_ONESTEP_SYNC)); + + info->rx_filters = ((1 << HWTSTAMP_FILTER_NONE) | + (1 << HWTSTAMP_FILTER_PTP_V1_L4_EVENT) | + (1 << HWTSTAMP_FILTER_PTP_V1_L4_SYNC) | + (1 << HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) | + (1 << HWTSTAMP_FILTER_PTP_V2_L4_EVENT) | + (1 << HWTSTAMP_FILTER_PTP_V2_L4_SYNC) | + (1 << HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ) | + (1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) | + (1 << HWTSTAMP_FILTER_PTP_V2_L2_SYNC) | + (1 << HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ) | + (1 << HWTSTAMP_FILTER_PTP_V2_EVENT) | + (1 << HWTSTAMP_FILTER_PTP_V2_SYNC) | + (1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ) | + (1 << HWTSTAMP_FILTER_ALL)); + return 0; +} + +int sxgbe_set_flow_ctrl(struct sxgbe_priv_data *priv, int rx, int tx) +{ + return 0; +} + +static void sxgbe_get_pauseparam(struct net_device *netdev, + struct ethtool_pauseparam *pause) +{ + struct sxgbe_priv_data *priv = netdev_priv(netdev); + + pause->rx_pause = priv->rx_pause; + pause->tx_pause = priv->tx_pause; +} + +static int sxgbe_set_pauseparam(struct net_device *netdev, + struct ethtool_pauseparam *pause) +{ + struct sxgbe_priv_data *priv = netdev_priv(netdev); + + if (pause->autoneg) + return -EINVAL; + + return sxgbe_set_flow_ctrl(priv, pause->rx_pause, pause->tx_pause); +} + + + +static void sxgbe_get_strings(struct net_device *dev, u32 stringset, u8 *data) +{ + int i; + u8 *p = data; + + switch (stringset) { + case ETH_SS_STATS: + for (i = 0; i < SXGBE_STATS_LEN; i++) { + memcpy(p, sxgbe_gstrings_stats[i].stat_string, + ETH_GSTRING_LEN); + p += ETH_GSTRING_LEN; + } + break; + default: + WARN_ON(1); + break; + } +} + +static int sxgbe_get_sset_count(struct net_device *netdev, int sset) +{ + int len; + + switch (sset) { + case ETH_SS_STATS: + len = SXGBE_STATS_LEN; + return len; + default: + return -EOPNOTSUPP; + } +} + +static void sxgbe_get_ethtool_stats(struct net_device *dev, + struct ethtool_stats *dummy, u64 *data) +{ + struct sxgbe_priv_data *priv = netdev_priv(dev); + int i, j = 0; + char *p; + + if (priv->eee_enabled) { + int val = phy_get_eee_err(priv->phydev); + if (val) + priv->xstats.eee_wakeup_error_n = val; + } + + for (i = 0; i < SXGBE_STATS_LEN; i++) { + p = (char *)priv + sxgbe_gstrings_stats[i].stat_offset; + data[j++] = (sxgbe_gstrings_stats[i].sizeof_stat == sizeof(u64)) + ? (*(u64 *)p) : (*(u32 *)p); + } +} + +static void sxgbe_get_channels(struct net_device *dev, + struct ethtool_channels *channel) +{ + channel->max_rx = SXGBE_MAX_RX_CHANNELS; + channel->max_tx = SXGBE_MAX_TX_CHANNELS; + channel->rx_count = SXGBE_RX_QUEUES; + channel->tx_count = SXGBE_TX_QUEUES; +} + +static u32 sxgbe_riwt2usec(u32 riwt, struct sxgbe_priv_data *priv) +{ + unsigned long clk = clk_get_rate(priv->sxgbe_clk); + + if (!clk) + return 0; + + return (riwt * 256) / (clk / 1000000); +} + +static u32 sxgbe_usec2riwt(u32 usec, struct sxgbe_priv_data *priv) +{ + unsigned long clk = clk_get_rate(priv->sxgbe_clk); + + if (!clk) + return 0; + + return (usec * (clk / 1000000)) / 256; +} + +static int sxgbe_get_coalesce(struct net_device *dev, + struct ethtool_coalesce *ec) +{ + struct sxgbe_priv_data *priv = netdev_priv(dev); + + if (priv->use_riwt) + ec->rx_coalesce_usecs = sxgbe_riwt2usec(priv->rx_riwt, priv); + + return 0; +} + +static int sxgbe_set_coalesce(struct net_device *dev, + struct ethtool_coalesce *ec) +{ + struct sxgbe_priv_data *priv = netdev_priv(dev); + unsigned int rx_riwt; + + rx_riwt = sxgbe_usec2riwt(ec->rx_coalesce_usecs, priv); + + if ((rx_riwt > SXGBE_MAX_DMA_RIWT) || (rx_riwt < SXGBE_MIN_DMA_RIWT)) + return -EINVAL; + else if (!priv->use_riwt) + return -EOPNOTSUPP; + + priv->rx_riwt = rx_riwt; + priv->hw->dma->rx_watchdog(priv->ioaddr, priv->rx_riwt); + + return 0; +} + +static int sxgbe_get_rss_hash_opts(struct sxgbe_priv_data *priv, + struct ethtool_rxnfc *cmd) +{ + cmd->data = 0; + + /* Report default options for RSS on sxgbe */ + switch (cmd->flow_type) { + case TCP_V4_FLOW: + case UDP_V4_FLOW: + cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; + case SCTP_V4_FLOW: + case AH_ESP_V4_FLOW: + case AH_V4_FLOW: + case ESP_V4_FLOW: + case IPV4_FLOW: + cmd->data |= RXH_IP_SRC | RXH_IP_DST; + break; + case TCP_V6_FLOW: + case UDP_V6_FLOW: + cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; + case SCTP_V6_FLOW: + case AH_ESP_V6_FLOW: + case AH_V6_FLOW: + case ESP_V6_FLOW: + case IPV6_FLOW: + cmd->data |= RXH_IP_SRC | RXH_IP_DST; + break; + default: + return -EINVAL; + } + + return 0; +} + +static int sxgbe_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd, + u32 *rule_locs) +{ + struct sxgbe_priv_data *priv = netdev_priv(dev); + int ret = -EOPNOTSUPP; + + switch (cmd->cmd) { + case ETHTOOL_GRXFH: + ret = sxgbe_get_rss_hash_opts(priv, cmd); + break; + default: + break; + } + + return ret; +} + +static int sxgbe_set_rss_hash_opt(struct sxgbe_priv_data *priv, + struct ethtool_rxnfc *cmd) +{ + u32 reg_val = 0; + + /* RSS does not support anything other than hashing + * to queues on src and dst IPs and ports + */ + if (cmd->data & ~(RXH_IP_SRC | RXH_IP_DST | + RXH_L4_B_0_1 | RXH_L4_B_2_3)) + return -EINVAL; + + switch (cmd->flow_type) { + case TCP_V4_FLOW: + case TCP_V6_FLOW: + if (!(cmd->data & RXH_IP_SRC) || + !(cmd->data & RXH_IP_DST) || + !(cmd->data & RXH_L4_B_0_1) || + !(cmd->data & RXH_L4_B_2_3)) + return -EINVAL; + reg_val = SXGBE_CORE_RSS_CTL_TCP4TE; + break; + case UDP_V4_FLOW: + case UDP_V6_FLOW: + if (!(cmd->data & RXH_IP_SRC) || + !(cmd->data & RXH_IP_DST) || + !(cmd->data & RXH_L4_B_0_1) || + !(cmd->data & RXH_L4_B_2_3)) + return -EINVAL; + reg_val = SXGBE_CORE_RSS_CTL_UDP4TE; + break; + case SCTP_V4_FLOW: + case AH_ESP_V4_FLOW: + case AH_V4_FLOW: + case ESP_V4_FLOW: + case AH_ESP_V6_FLOW: + case AH_V6_FLOW: + case ESP_V6_FLOW: + case SCTP_V6_FLOW: + case IPV4_FLOW: + case IPV6_FLOW: + if (!(cmd->data & RXH_IP_SRC) || + !(cmd->data & RXH_IP_DST) || + (cmd->data & RXH_L4_B_0_1) || + (cmd->data & RXH_L4_B_2_3)) + return -EINVAL; + reg_val = SXGBE_CORE_RSS_CTL_IP2TE; + break; + default: + return -EINVAL; + } + + /* Read SXGBE RSS control register and update */ + reg_val |= readl(priv->ioaddr + SXGBE_CORE_RSS_CTL_REG); + writel(reg_val, priv->ioaddr + SXGBE_CORE_RSS_CTL_REG); + readl(priv->ioaddr + SXGBE_CORE_RSS_CTL_REG); + + return 0; +} + +static int sxgbe_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd) +{ + struct sxgbe_priv_data *priv = netdev_priv(dev); + int ret = -EOPNOTSUPP; + + switch (cmd->cmd) { + case ETHTOOL_SRXFH: + ret = sxgbe_set_rss_hash_opt(priv, cmd); + break; + default: + break; + } + + return ret; +} + +static void sxgbe_get_regs(struct net_device *dev, + struct ethtool_regs *regs, void *space) +{ + struct sxgbe_priv_data *priv = netdev_priv(dev); + u32 *reg_space = (u32 *)space; + int reg_offset; + int reg_ix = 0; + void __iomem *ioaddr = priv->ioaddr; + + memset(reg_space, 0x0, REG_SPACE_SIZE); + + /* MAC registers */ + for (reg_offset = START_MAC_REG_OFFSET; + reg_offset <= MAX_MAC_REG_OFFSET; reg_offset += 4) { + reg_space[reg_ix] = readl(ioaddr + reg_offset); + reg_ix++; + } + + /* MTL registers */ + for (reg_offset = START_MTL_REG_OFFSET; + reg_offset <= MAX_MTL_REG_OFFSET; reg_offset += 4) { + reg_space[reg_ix] = readl(ioaddr + reg_offset); + reg_ix++; + } + + /* DMA registers */ + for (reg_offset = START_DMA_REG_OFFSET; + reg_offset <= MAX_DMA_REG_OFFSET; reg_offset += 4) { + reg_space[reg_ix] = readl(ioaddr + reg_offset); + reg_ix++; + } +} + +static int sxgbe_get_regs_len(struct net_device *dev) +{ + return REG_SPACE_SIZE; +} + static const struct ethtool_ops sxgbe_ethtool_ops = { - .get_eee = sxgbe_ethtool_get_eee, - .set_eee = sxgbe_ethtool_set_eee, + .get_drvinfo = sxgbe_getdrvinfo, + .get_settings = sxgbe_getsettings, + .set_settings = sxgbe_setsettings, + .get_msglevel = sxgbe_getmsglevel, + .set_msglevel = sxgbe_setmsglevel, + .get_link = ethtool_op_get_link, + .get_ts_info = sxgbe_get_ts_info, + .get_pauseparam = sxgbe_get_pauseparam, + .set_pauseparam = sxgbe_set_pauseparam, + .get_strings = sxgbe_get_strings, + .get_ethtool_stats = sxgbe_get_ethtool_stats, + .get_sset_count = sxgbe_get_sset_count, + .get_channels = sxgbe_get_channels, + .get_coalesce = sxgbe_get_coalesce, + .set_coalesce = sxgbe_set_coalesce, + .get_rxnfc = sxgbe_get_rxnfc, + .set_rxnfc = sxgbe_set_rxnfc, + .get_regs = sxgbe_get_regs, + .get_regs_len = sxgbe_get_regs_len, + .get_eee = sxgbe_get_eee, + .set_eee = sxgbe_set_eee, .get_wol = sxgbe_get_wol, .set_wol = sxgbe_set_wol, }; diff --git a/drivers/net/ethernet/samsung/sxgbe_main.c b/drivers/net/ethernet/samsung/sxgbe_main.c index 21a06ae..5482e3d 100644 --- a/drivers/net/ethernet/samsung/sxgbe_main.c +++ b/drivers/net/ethernet/samsung/sxgbe_main.c @@ -59,7 +59,6 @@ static int debug = -1; static int sxgbe_phyaddr = -1; static int dma_txsize = DMA_TX_SIZE; static int dma_rxsize = DMA_RX_SIZE; -static int flow_ctrl = SXGBE_FLOW_OFF; static int pause = SXGBE_PAUSE_TIME; static int tx_tc = TC_DEFAULT; static int rx_tc = TC_DEFAULT; @@ -71,7 +70,6 @@ module_param(debug, int, S_IRUGO | S_IWUSR); module_param(sxgbe_phyaddr, int, S_IRUGO); module_param(dma_txsize, int, S_IRUGO | S_IWUSR); module_param(dma_rxsize, int, S_IRUGO | S_IWUSR); -module_param(flow_ctrl, int, S_IRUGO | S_IWUSR); module_param(pause, int, S_IRUGO | S_IWUSR); module_param(tx_tc, int, S_IRUGO | S_IWUSR); module_param(rx_tc, int, S_IRUGO | S_IWUSR); @@ -105,10 +103,6 @@ static void sxgbe_verify_args(void) dma_txsize = DMA_TX_SIZE; if (unlikely((buf_sz < DMA_BUFFER_SIZE) || (buf_sz > BUF_SIZE_16KiB))) buf_sz = DMA_BUFFER_SIZE; - if (unlikely(flow_ctrl > 1)) - flow_ctrl = SXGBE_FLOW_AUTO; - else if (likely(flow_ctrl < 0)) - flow_ctrl = SXGBE_FLOW_OFF; if (unlikely((pause < 0) || (pause > 0xffff))) pause = SXGBE_PAUSE_TIME; if (unlikely(eee_timer < 0)) @@ -2204,9 +2198,6 @@ struct sxgbe_priv_data *sxgbe_dvr_probe(struct device *device, priv->msg_enable = netif_msg_init(debug, default_msg_level); - if (flow_ctrl) - priv->flow_ctrl = SXGBE_FLOW_AUTO; /* RX/TX pause on */ - /* Enable TCP segmentation offload for all DMA channels */ if (priv->hw_cap.tcpseg_offload) { SXGBE_FOR_EACH_QUEUE(SXGBE_TX_QUEUES, queue_num) { @@ -2220,6 +2211,11 @@ struct sxgbe_priv_data *sxgbe_dvr_probe(struct device *device, priv->rxcsum_insertion = true; } + /* Initialise pause frame settings */ + priv->rx_pause = 1; + priv->tx_pause = 1; + sxgbe_set_flow_ctrl(priv, priv->rx_pause, priv->tx_pause); + /* Rx Watchdog is available, enable depend on platform data */ if (!priv->plat->riwt_off) { priv->use_riwt = 1; diff --git a/drivers/net/ethernet/samsung/sxgbe_reg.h b/drivers/net/ethernet/samsung/sxgbe_reg.h index bd85923..ed1226d 100644 --- a/drivers/net/ethernet/samsung/sxgbe_reg.h +++ b/drivers/net/ethernet/samsung/sxgbe_reg.h @@ -195,6 +195,12 @@ #define SXGBE_CORE_RSS_ADD_REG 0x0C88 #define SXGBE_CORE_RSS_DATA_REG 0x0C8C +/* RSS control register bits */ +#define SXGBE_CORE_RSS_CTL_UDP4TE BIT(3) +#define SXGBE_CORE_RSS_CTL_TCP4TE BIT(2) +#define SXGBE_CORE_RSS_CTL_IP2TE BIT(1) +#define SXGBE_CORE_RSS_CTL_RSSE BIT(0) + /* IEEE 1588 registers */ #define SXGBE_CORE_TSTAMP_CTL_REG 0x0D00 #define SXGBE_CORE_SUBSEC_INC_REG 0x0D04