From patchwork Wed Sep 30 17:48:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Kinzie X-Patchwork-Id: 7337 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 582728E71; Wed, 30 Sep 2015 19:48:40 +0200 (CEST) Received: from mail-ig0-f176.google.com (mail-ig0-f176.google.com [209.85.213.176]) by dpdk.org (Postfix) with ESMTP id C64568E61 for ; Wed, 30 Sep 2015 19:48:36 +0200 (CEST) Received: by igcrk20 with SMTP id rk20so108229704igc.1 for ; Wed, 30 Sep 2015 10:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tn8WIy24bqgGFt6xCAUQoqRYWjD9RDg9QvrytoGOAfM=; b=NFKCHlw1RTmP6osM0YuCQoc0hSs95wBKkOkpkQx9ig9DLwcEEUnrwMwcWOT0sQtdXV KpbzrjYzyTDfR0pfbzf2JAwDB8QJVJIQ8T7niyM5cuSZhELF2ruYP/7A0Lf4VWmSAxah 365K8t0EQS3GHMZ8lMpNOQ717RwYWrZ8bVIwNRw8Xv4dExtJF/+sDaBsj7CoP971LHH4 7GMePukhnOVQnGwQ+IO3JhGX1Mj51REQjNNTE087cOBHSI5+VwJ9DOcwqIlF5mnfpIQw if4Wc7cmwP4ONc8QJJB7Gd0k3ehOA8ArwQ/rMemmPjxQPMmgOvgywsHYNc+7rYa9aVNL YlyA== X-Received: by 10.50.73.97 with SMTP id k1mr6555450igv.43.1443635316196; Wed, 30 Sep 2015 10:48:36 -0700 (PDT) Received: from buildhost2.vyatta.com. ([144.49.197.22]) by smtp.gmail.com with ESMTPSA id b10sm753288igb.9.2015.09.30.10.48.34 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Sep 2015 10:48:35 -0700 (PDT) From: Eric Kinzie To: dev@dpdk.org Date: Wed, 30 Sep 2015 10:48:16 -0700 Message-Id: <1443635297-13106-4-git-send-email-ehkinzie@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1443635297-13106-1-git-send-email-ehkinzie@gmail.com> References: <1443635297-13106-1-git-send-email-ehkinzie@gmail.com> Cc: Eric Kinzie Subject: [dpdk-dev] [PATCH v5 3/4] bond mode 4: allow external state machine 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Eric Kinzie Provide functions to allow an external 802.3ad state machine to transmit and recieve LACPDUs and to set the collection/distribution flags on slave interfaces. Size of struct rte_eth_bond_8023ad_conf changed. Increment LIBABIVER and version bond_mode_8023ad_setup and bond_mode_8023ad_conf_get functions. Signed-off-by: Eric Kinzie --- drivers/net/bonding/Makefile | 2 +- drivers/net/bonding/rte_eth_bond_8023ad.c | 240 ++++++++++++++++++++- drivers/net/bonding/rte_eth_bond_8023ad.h | 44 ++++ drivers/net/bonding/rte_eth_bond_8023ad_private.h | 28 +++ drivers/net/bonding/rte_eth_bond_version.map | 3 + 5 files changed, 314 insertions(+), 3 deletions(-) diff --git a/drivers/net/bonding/Makefile b/drivers/net/bonding/Makefile index dee0875..8b892ca 100644 --- a/drivers/net/bonding/Makefile +++ b/drivers/net/bonding/Makefile @@ -41,7 +41,7 @@ CFLAGS += $(WERROR_FLAGS) EXPORT_MAP := rte_eth_bond_version.map -LIBABIVER := 1 +LIBABIVER := 2 # # all source are stored in SRCS-y diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c index 08f679f..312ec11 100644 --- a/drivers/net/bonding/rte_eth_bond_8023ad.c +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c @@ -39,9 +39,12 @@ #include #include #include +#include #include "rte_eth_bond_private.h" +static void bond_mode_8023ad_ext_periodic_cb(void *arg); + #ifdef RTE_LIBRTE_BOND_DEBUG_8023AD #define MODE4_DEBUG(fmt, ...) RTE_LOG(DEBUG, PMD, "%6u [Port %u: %s] " fmt, \ bond_dbg_get_time_diff_ms(), slave_id, \ @@ -999,7 +1002,28 @@ bond_mode_8023ad_mac_address_update(struct rte_eth_dev *bond_dev) } void -bond_mode_8023ad_conf_get(struct rte_eth_dev *dev, +bond_mode_8023ad_conf_get_v20(struct rte_eth_dev *dev, + struct rte_eth_bond_8023ad_conf *conf) +{ + struct bond_dev_private *internals = dev->data->dev_private; + struct mode8023ad_private *mode4 = &internals->mode4; + uint64_t ms_ticks = rte_get_tsc_hz() / 1000; + + conf->fast_periodic_ms = mode4->fast_periodic_timeout / ms_ticks; + conf->slow_periodic_ms = mode4->slow_periodic_timeout / ms_ticks; + conf->short_timeout_ms = mode4->short_timeout / ms_ticks; + conf->long_timeout_ms = mode4->long_timeout / ms_ticks; + conf->aggregate_wait_timeout_ms = mode4->aggregate_wait_timeout / ms_ticks; + conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks; + conf->update_timeout_ms = mode4->update_timeout_us / 1000; + conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks; + conf->slowrx_cb = mode4->slowrx_cb; +} + +VERSION_SYMBOL(bond_mode_8023ad_conf_get, _v20, 2.0); + +void +bond_mode_8023ad_conf_get_v21(struct rte_eth_dev *dev, struct rte_eth_bond_8023ad_conf *conf) { struct bond_dev_private *internals = dev->data->dev_private; @@ -1014,10 +1038,15 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev, conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks; conf->update_timeout_ms = mode4->update_timeout_us / 1000; conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks; + conf->slowrx_cb = mode4->slowrx_cb; } +BIND_DEFAULT_SYMBOL(bond_mode_8023ad_conf_get, _v21, 2.1); +MAP_STATIC_SYMBOL(void bond_mode_8023ad_conf_get(struct rte_eth_dev *dev, struct rte_eth_bond_8023ad_conf *conf), \ + bond_mode_8023ad_conf_get_v21); + void -bond_mode_8023ad_setup(struct rte_eth_dev *dev, +bond_mode_8023ad_setup_v20(struct rte_eth_dev *dev, struct rte_eth_bond_8023ad_conf *conf) { struct rte_eth_bond_8023ad_conf def_conf; @@ -1047,6 +1076,50 @@ bond_mode_8023ad_setup(struct rte_eth_dev *dev, mode4->update_timeout_us = conf->update_timeout_ms * 1000; } +VERSION_SYMBOL(bond_mode_8023ad_setup, _v20, 2.0); + +void +bond_mode_8023ad_setup_v21(struct rte_eth_dev *dev, + struct rte_eth_bond_8023ad_conf *conf) +{ + struct rte_eth_bond_8023ad_conf def_conf; + struct bond_dev_private *internals = dev->data->dev_private; + struct mode8023ad_private *mode4 = &internals->mode4; + uint64_t ms_ticks = rte_get_tsc_hz() / 1000; + + if (conf == NULL) { + conf = &def_conf; + conf->fast_periodic_ms = BOND_8023AD_FAST_PERIODIC_MS; + conf->slow_periodic_ms = BOND_8023AD_SLOW_PERIODIC_MS; + conf->short_timeout_ms = BOND_8023AD_SHORT_TIMEOUT_MS; + conf->long_timeout_ms = BOND_8023AD_LONG_TIMEOUT_MS; + conf->aggregate_wait_timeout_ms = BOND_8023AD_AGGREGATE_WAIT_TIMEOUT_MS; + conf->tx_period_ms = BOND_8023AD_TX_MACHINE_PERIOD_MS; + conf->rx_marker_period_ms = BOND_8023AD_RX_MARKER_PERIOD_MS; + conf->update_timeout_ms = BOND_MODE_8023AX_UPDATE_TIMEOUT_MS; + conf->slowrx_cb = NULL; + } + + bond_mode_8023ad_stop(dev); + + mode4->fast_periodic_timeout = conf->fast_periodic_ms * ms_ticks; + mode4->slow_periodic_timeout = conf->slow_periodic_ms * ms_ticks; + mode4->short_timeout = conf->short_timeout_ms * ms_ticks; + mode4->long_timeout = conf->long_timeout_ms * ms_ticks; + mode4->aggregate_wait_timeout = conf->aggregate_wait_timeout_ms * ms_ticks; + mode4->tx_period_timeout = conf->tx_period_ms * ms_ticks; + mode4->rx_marker_timeout = conf->rx_marker_period_ms * ms_ticks; + mode4->update_timeout_us = conf->update_timeout_ms * 1000; + mode4->slowrx_cb = conf->slowrx_cb; + + if (dev->data->dev_started) + bond_mode_8023ad_start(dev); +} + +BIND_DEFAULT_SYMBOL(bond_mode_8023ad_setup, _v21, 2.1); +MAP_STATIC_SYMBOL(void bond_mode_8023ad_setup(struct rte_eth_dev *dev, struct rte_eth_bond_8023ad_conf *conf), \ + bond_mode_8023ad_setup_v21); + int bond_mode_8023ad_enable(struct rte_eth_dev *bond_dev) { @@ -1062,6 +1135,13 @@ bond_mode_8023ad_enable(struct rte_eth_dev *bond_dev) int bond_mode_8023ad_start(struct rte_eth_dev *bond_dev) { + struct bond_dev_private *internals = bond_dev->data->dev_private; + struct mode8023ad_private *mode4 = &internals->mode4; + + if (mode4->slowrx_cb) + return rte_eal_alarm_set(BOND_MODE_8023AX_UPDATE_TIMEOUT_MS * 1000, + &bond_mode_8023ad_ext_periodic_cb, bond_dev); + return rte_eal_alarm_set(BOND_MODE_8023AX_UPDATE_TIMEOUT_MS * 1000, &bond_mode_8023ad_periodic_cb, bond_dev); } @@ -1069,6 +1149,13 @@ bond_mode_8023ad_start(struct rte_eth_dev *bond_dev) void bond_mode_8023ad_stop(struct rte_eth_dev *bond_dev) { + struct bond_dev_private *internals = bond_dev->data->dev_private; + struct mode8023ad_private *mode4 = &internals->mode4; + + if (mode4->slowrx_cb) { + rte_eal_alarm_cancel(&bond_mode_8023ad_ext_periodic_cb, bond_dev); + return; + } rte_eal_alarm_cancel(&bond_mode_8023ad_periodic_cb, bond_dev); } @@ -1215,3 +1302,152 @@ rte_eth_bond_8023ad_slave_info(uint8_t port_id, uint8_t slave_id, info->agg_port_id = port->aggregator_port_id; return 0; } + +int +rte_eth_bond_8023ad_ext_collect(uint8_t port_id, uint8_t slave_id, int enabled) +{ + struct rte_eth_dev *bond_dev; + struct bond_dev_private *internals; + struct mode8023ad_private *mode4; + struct port *port; + + if (rte_eth_bond_mode_get(port_id) != BONDING_MODE_8023AD) + return -EINVAL; + + bond_dev = &rte_eth_devices[port_id]; + + if (!bond_dev->data->dev_started) + return -EINVAL; + + internals = bond_dev->data->dev_private; + if (find_slave_by_id(internals->active_slaves, + internals->active_slave_count, slave_id) == + internals->active_slave_count) + return -EINVAL; + + mode4 = &internals->mode4; + if (mode4->slowrx_cb == NULL) + return -EINVAL; + + port = &mode_8023ad_ports[slave_id]; + + if (enabled) + ACTOR_STATE_SET(port, COLLECTING); + else + ACTOR_STATE_CLR(port, COLLECTING); + + return 0; +} + +int +rte_eth_bond_8023ad_ext_distrib(uint8_t port_id, uint8_t slave_id, int enabled) +{ + struct rte_eth_dev *bond_dev; + struct bond_dev_private *internals; + struct mode8023ad_private *mode4; + struct port *port; + + if (rte_eth_bond_mode_get(port_id) != BONDING_MODE_8023AD) + return -EINVAL; + + bond_dev = &rte_eth_devices[port_id]; + + if (!bond_dev->data->dev_started) + return -EINVAL; + + internals = bond_dev->data->dev_private; + if (find_slave_by_id(internals->active_slaves, + internals->active_slave_count, slave_id) == + internals->active_slave_count) + return -EINVAL; + + mode4 = &internals->mode4; + if (mode4->slowrx_cb == NULL) + return -EINVAL; + + port = &mode_8023ad_ports[slave_id]; + + if (enabled) + ACTOR_STATE_SET(port, DISTRIBUTING); + else + ACTOR_STATE_CLR(port, DISTRIBUTING); + + return 0; +} + +int +rte_eth_bond_8023ad_ext_slowtx(uint8_t port_id, uint8_t slave_id, + struct rte_mbuf *lacp_pkt) +{ + struct rte_eth_dev *bond_dev; + struct bond_dev_private *internals; + struct mode8023ad_private *mode4; + struct port *port; + + if (rte_eth_bond_mode_get(port_id) != BONDING_MODE_8023AD) + return -EINVAL; + + bond_dev = &rte_eth_devices[port_id]; + + if (!bond_dev->data->dev_started) + return -EINVAL; + + internals = bond_dev->data->dev_private; + if (find_slave_by_id(internals->active_slaves, + internals->active_slave_count, slave_id) == + internals->active_slave_count) + return -EINVAL; + + mode4 = &internals->mode4; + if (mode4->slowrx_cb == NULL) + return -EINVAL; + + port = &mode_8023ad_ports[slave_id]; + + if (rte_pktmbuf_pkt_len(lacp_pkt) < sizeof(struct lacpdu_header)) + return -EINVAL; + + struct lacpdu_header *lacp; + + /* only enqueue LACPDUs */ + lacp = rte_pktmbuf_mtod(lacp_pkt, struct lacpdu_header *); + if (lacp->lacpdu.subtype != SLOW_SUBTYPE_LACP) + return -EINVAL; + + MODE4_DEBUG("sending LACP frame\n"); + + return rte_ring_enqueue(port->tx_ring, lacp_pkt); +} + +static void +bond_mode_8023ad_ext_periodic_cb(void *arg) +{ + struct rte_eth_dev *bond_dev = arg; + struct bond_dev_private *internals = bond_dev->data->dev_private; + struct mode8023ad_private *mode4 = &internals->mode4; + struct port *port; + void *pkt = NULL; + uint16_t i, slave_id; + + for (i = 0; i < internals->active_slave_count; i++) { + slave_id = internals->active_slaves[i]; + port = &mode_8023ad_ports[slave_id]; + + if (rte_ring_dequeue(port->rx_ring, &pkt) == 0) { + struct rte_mbuf *lacp_pkt = pkt; + struct lacpdu_header *lacp; + + lacp = rte_pktmbuf_mtod(lacp_pkt, + struct lacpdu_header *); + RTE_VERIFY(lacp->lacpdu.subtype == SLOW_SUBTYPE_LACP); + + /* This is LACP frame so pass it to rx callback. + * Callback is responsible for freeing mbuf. + */ + mode4->slowrx_cb(slave_id, lacp_pkt); + } + } + + rte_eal_alarm_set(internals->mode4.update_timeout_us, + bond_mode_8023ad_ext_periodic_cb, arg); +} diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.h b/drivers/net/bonding/rte_eth_bond_8023ad.h index ebd0e93..8cfa3d3 100644 --- a/drivers/net/bonding/rte_eth_bond_8023ad.h +++ b/drivers/net/bonding/rte_eth_bond_8023ad.h @@ -64,6 +64,8 @@ extern "C" { #define MARKER_TLV_TYPE_INFO 0x01 #define MARKER_TLV_TYPE_RESP 0x02 +typedef void (*rte_eth_bond_8023ad_ext_slowrx_fn)(uint8_t slave_id, struct rte_mbuf *lacp_pkt); + enum rte_bond_8023ad_selection { UNSELECTED, STANDBY, @@ -157,6 +159,7 @@ struct rte_eth_bond_8023ad_conf { uint32_t tx_period_ms; uint32_t rx_marker_period_ms; uint32_t update_timeout_ms; + rte_eth_bond_8023ad_ext_slowrx_fn slowrx_cb; }; struct rte_eth_bond_8023ad_slave_info { @@ -219,4 +222,45 @@ rte_eth_bond_8023ad_slave_info(uint8_t port_id, uint8_t slave_id, } #endif +/** + * Configure a slave port to start collecting. + * + * @param port_id Bonding device id + * @param slave_id Port id of valid slave. + * @param enabled Non-zero when collection enabled. + * @return + * 0 - if ok + * -EINVAL if slave is not valid. + */ +int +rte_eth_bond_8023ad_ext_collect(uint8_t port_id, uint8_t slave_id, int enabled); + +/** + * Configure a slave port to start distributing. + * + * @param port_id Bonding device id + * @param slave_id Port id of valid slave. + * @param enabled Non-zero when distribution enabled. + * @return + * 0 - if ok + * -EINVAL if slave is not valid. + */ +int +rte_eth_bond_8023ad_ext_distrib(uint8_t port_id, uint8_t slave_id, int enabled); + +/** + * LACPDU transmit path for external 802.3ad state machine. Caller retains + * ownership of the packet on failure. + * + * @param port_id Bonding device id + * @param slave_id Port ID of valid slave device. + * @param lacp_pkt mbuf containing LACPDU. + * + * @return + * 0 on success, negative value otherwise. + */ +int +rte_eth_bond_8023ad_ext_slowtx(uint8_t port_id, uint8_t slave_id, + struct rte_mbuf *lacp_pkt); + #endif /* RTE_ETH_BOND_8023AD_H_ */ diff --git a/drivers/net/bonding/rte_eth_bond_8023ad_private.h b/drivers/net/bonding/rte_eth_bond_8023ad_private.h index 8adee70..cb39004 100644 --- a/drivers/net/bonding/rte_eth_bond_8023ad_private.h +++ b/drivers/net/bonding/rte_eth_bond_8023ad_private.h @@ -39,6 +39,7 @@ #include #include #include +#include #include "rte_eth_bond_8023ad.h" @@ -173,6 +174,8 @@ struct mode8023ad_private { uint64_t tx_period_timeout; uint64_t rx_marker_timeout; uint64_t update_timeout_us; + rte_eth_bond_8023ad_ext_slowrx_fn slowrx_cb; + uint8_t external_sm; }; /** @@ -211,6 +214,31 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev, void bond_mode_8023ad_setup(struct rte_eth_dev *dev, struct rte_eth_bond_8023ad_conf *conf); +void __vsym +bond_mode_8023ad_setup_v20(struct rte_eth_dev *dev, + struct rte_eth_bond_8023ad_conf *conf); +void __vsym +bond_mode_8023ad_setup_v21(struct rte_eth_dev *dev, + struct rte_eth_bond_8023ad_conf *conf); + +/** + * @internal + * + * Retreive mode 4 configuration of bonded interface. + * + * @param dev Bonded interface + * @param conf Bonded interface configuration + */ +void +bond_mode_8023ad_conf_get(struct rte_eth_dev *dev, + struct rte_eth_bond_8023ad_conf *conf); +void __vsym +bond_mode_8023ad_conf_get_v20(struct rte_eth_dev *dev, + struct rte_eth_bond_8023ad_conf *conf); +void __vsym +bond_mode_8023ad_conf_get_v21(struct rte_eth_dev *dev, + struct rte_eth_bond_8023ad_conf *conf); + /** * @internal diff --git a/drivers/net/bonding/rte_eth_bond_version.map b/drivers/net/bonding/rte_eth_bond_version.map index 22bd920..0b76e41 100644 --- a/drivers/net/bonding/rte_eth_bond_version.map +++ b/drivers/net/bonding/rte_eth_bond_version.map @@ -17,6 +17,9 @@ DPDK_2.0 { rte_eth_bond_slaves_get; rte_eth_bond_xmit_policy_get; rte_eth_bond_xmit_policy_set; + rte_eth_bond_8023ad_ext_collect; + rte_eth_bond_8023ad_ext_distrib; + rte_eth_bond_8023ad_ext_slowtx; local: *; };