From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nbfkord-smmo01.seg.att.com (nbfkord-smmo01.seg.att.com [209.65.160.76]) by dpdk.org (Postfix) with ESMTP id BD82E5587 for ; Tue, 29 Nov 2016 17:21:02 +0100 (CET) Received: from unknown [12.187.104.26] (EHLO nbfkord-smmo01.seg.att.com) by nbfkord-smmo01.seg.att.com(mxl_mta-7.2.4-7) with ESMTP id eeaad385.2b3eaf88b940.83703.00-2487.174164.nbfkord-smmo01.seg.att.com (envelope-from ); Tue, 29 Nov 2016 16:21:02 +0000 (UTC) X-MXL-Hash: 583daaee4a312a1c-258662ad123deaafa28753d2344ccf9dc2cdb491 Received: from unknown [12.187.104.26] by nbfkord-smmo01.seg.att.com(mxl_mta-7.2.4-7) with SMTP id aeaad385.0.83424.00-2359.174064.nbfkord-smmo01.seg.att.com (envelope-from ); Tue, 29 Nov 2016 16:20:59 +0000 (UTC) X-MXL-Hash: 583daaeb3638e3e3-396ef18d6a84bff0c67a1ea33f6ef99ae636b23c Received: from ocex03.SolarFlarecom.com (10.20.40.36) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Tue, 29 Nov 2016 08:20:26 -0800 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25 via Frontend Transport; Tue, 29 Nov 2016 08:20:25 -0800 Received: from uklogin.uk.solarflarecom.com (uklogin.uk.solarflarecom.com [10.17.10.10]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id uATGKO6T030023; Tue, 29 Nov 2016 16:20:24 GMT Received: from uklogin.uk.solarflarecom.com (localhost.localdomain [127.0.0.1]) by uklogin.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id uATGKM1n021233; Tue, 29 Nov 2016 16:20:24 GMT From: Andrew Rybchenko To: CC: Date: Tue, 29 Nov 2016 16:19:13 +0000 Message-ID: <1480436367-20749-42-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1480436367-20749-1-git-send-email-arybchenko@solarflare.com> References: <1479740470-6723-1-git-send-email-arybchenko@solarflare.com> <1480436367-20749-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-AnalysisOut: [v=2.1 cv=UoJlQrEB c=1 sm=1 tr=0 a=8BlWFWvVlq5taO8ncb8nKg==] X-AnalysisOut: [:17 a=L24OOQBejmoA:10 a=zRKbQ67AAAAA:8 a=QtmSuGzYx-VwVVu5U] X-AnalysisOut: [-UA:9 a=PA03WX8tBzeizutn5_OT:22] X-Spam: [F=0.2000000000; CM=0.500; S=0.200(2015072901)] X-MAIL-FROM: X-SOURCE-IP: [12.187.104.26] Subject: [dpdk-dev] [PATCH v2 41/55] net/sfc: minimum port control sufficient to receive traffic X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Nov 2016 16:21:03 -0000 Reviewed-by: Andy Moreton Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/Makefile | 1 + drivers/net/sfc/sfc.c | 16 ++++++ drivers/net/sfc/sfc.h | 12 ++++ drivers/net/sfc/sfc_ethdev.c | 2 + drivers/net/sfc/sfc_port.c | 131 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 162 insertions(+) create mode 100644 drivers/net/sfc/sfc_port.c diff --git a/drivers/net/sfc/Makefile b/drivers/net/sfc/Makefile index 3286fd8..04c1db1 100644 --- a/drivers/net/sfc/Makefile +++ b/drivers/net/sfc/Makefile @@ -84,6 +84,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc.c SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_mcdi.c SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_intr.c SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_ev.c +SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_port.c VPATH += $(SRCDIR)/base diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c index 6870efe..01e0c94 100644 --- a/drivers/net/sfc/sfc.c +++ b/drivers/net/sfc/sfc.c @@ -266,10 +266,17 @@ sfc_start(struct sfc_adapter *sa) if (rc != 0) goto fail_ev_start; + rc = sfc_port_start(sa); + if (rc != 0) + goto fail_port_start; + sa->state = SFC_ADAPTER_STARTED; sfc_log_init(sa, "done"); return 0; +fail_port_start: + sfc_ev_stop(sa); + fail_ev_start: sfc_intr_stop(sa); @@ -305,6 +312,7 @@ sfc_stop(struct sfc_adapter *sa) sa->state = SFC_ADAPTER_STOPPING; + sfc_port_stop(sa); sfc_ev_stop(sa); sfc_intr_stop(sa); efx_nic_fini(sa->nic); @@ -337,10 +345,17 @@ sfc_configure(struct sfc_adapter *sa) if (rc != 0) goto fail_ev_init; + rc = sfc_port_init(sa); + if (rc != 0) + goto fail_port_init; + sa->state = SFC_ADAPTER_CONFIGURED; sfc_log_init(sa, "done"); return 0; +fail_port_init: + sfc_ev_fini(sa); + fail_ev_init: sfc_intr_fini(sa); @@ -361,6 +376,7 @@ sfc_close(struct sfc_adapter *sa) SFC_ASSERT(sa->state == SFC_ADAPTER_CONFIGURED); sa->state = SFC_ADAPTER_CLOSING; + sfc_port_fini(sa); sfc_ev_fini(sa); sfc_intr_fini(sa); diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index 104aee4..042e504 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -115,6 +115,12 @@ struct sfc_intr { struct sfc_evq_info; +struct sfc_port { + unsigned int flow_ctrl; + boolean_t flow_ctrl_autoneg; + size_t pdu; +}; + /* Adapter private data */ struct sfc_adapter { /* @@ -136,6 +142,7 @@ struct sfc_adapter { struct sfc_mcdi mcdi; struct sfc_intr intr; + struct sfc_port port; unsigned int rxq_max; unsigned int txq_max; @@ -204,6 +211,11 @@ void sfc_intr_fini(struct sfc_adapter *sa); int sfc_intr_start(struct sfc_adapter *sa); void sfc_intr_stop(struct sfc_adapter *sa); +int sfc_port_init(struct sfc_adapter *sa); +void sfc_port_fini(struct sfc_adapter *sa); +int sfc_port_start(struct sfc_adapter *sa); +void sfc_port_stop(struct sfc_adapter *sa); + #ifdef __cplusplus } #endif diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 3d22654..316723e 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -47,6 +47,8 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) RTE_SET_USED(dev_info); sfc_log_init(sa, "entry"); + + dev_info->max_rx_pktlen = EFX_MAC_PDU_MAX; } static int diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c new file mode 100644 index 0000000..844363c --- /dev/null +++ b/drivers/net/sfc/sfc_port.c @@ -0,0 +1,131 @@ +/*- + * Copyright (c) 2016 Solarflare Communications Inc. + * All rights reserved. + * + * This software was jointly developed between OKTET Labs (under contract + * for Solarflare) and Solarflare Communications, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "efx.h" + +#include "sfc.h" +#include "sfc_log.h" + + +int +sfc_port_start(struct sfc_adapter *sa) +{ + struct sfc_port *port = &sa->port; + int rc; + + sfc_log_init(sa, "entry"); + + sfc_log_init(sa, "init filters"); + rc = efx_filter_init(sa->nic); + if (rc != 0) + goto fail_filter_init; + + sfc_log_init(sa, "init port"); + rc = efx_port_init(sa->nic); + if (rc != 0) + goto fail_port_init; + + sfc_log_init(sa, "set MAC PDU %u", (unsigned int)port->pdu); + rc = efx_mac_pdu_set(sa->nic, port->pdu); + if (rc != 0) + goto fail_mac_pdu_set; + + sfc_log_init(sa, "set MAC address"); + rc = efx_mac_addr_set(sa->nic, + sa->eth_dev->data->mac_addrs[0].addr_bytes); + if (rc != 0) + goto fail_mac_addr_set; + + sfc_log_init(sa, "set MAC filters"); + rc = efx_mac_filter_set(sa->nic, B_TRUE, B_TRUE, B_TRUE, B_TRUE); + if (rc != 0) + goto fail_mac_filter_set; + + sfc_log_init(sa, "disable MAC drain"); + rc = efx_mac_drain(sa->nic, B_FALSE); + if (rc != 0) + goto fail_mac_drain; + + sfc_log_init(sa, "done"); + return 0; + +fail_mac_drain: +fail_mac_filter_set: +fail_mac_addr_set: +fail_mac_pdu_set: + efx_port_fini(sa->nic); + +fail_port_init: + efx_filter_fini(sa->nic); + +fail_filter_init: + sfc_log_init(sa, "failed %d", rc); + return rc; +} + +void +sfc_port_stop(struct sfc_adapter *sa) +{ + sfc_log_init(sa, "entry"); + + efx_mac_drain(sa->nic, B_TRUE); + efx_port_fini(sa->nic); + efx_filter_fini(sa->nic); + + sfc_log_init(sa, "done"); +} + +int +sfc_port_init(struct sfc_adapter *sa) +{ + const struct rte_eth_dev_data *dev_data = sa->eth_dev->data; + struct sfc_port *port = &sa->port; + + sfc_log_init(sa, "entry"); + + /* Enable flow control by default */ + port->flow_ctrl = EFX_FCNTL_RESPOND | EFX_FCNTL_GENERATE; + port->flow_ctrl_autoneg = B_TRUE; + + if (dev_data->dev_conf.rxmode.jumbo_frame) + port->pdu = dev_data->dev_conf.rxmode.max_rx_pkt_len; + else + port->pdu = EFX_MAC_PDU(dev_data->mtu); + + sfc_log_init(sa, "done"); + return 0; +} + +void +sfc_port_fini(struct sfc_adapter *sa) +{ + sfc_log_init(sa, "entry"); + + sfc_log_init(sa, "done"); +} -- 2.5.5