From owner-svn-src-stable@freebsd.org Sun Jan 1 19:06:03 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 70A33C9AA17; Sun, 1 Jan 2017 19:06:03 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4B3AF1964; Sun, 1 Jan 2017 19:06:03 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v01J62Ic044571; Sun, 1 Jan 2017 19:06:02 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v01J62uX044566; Sun, 1 Jan 2017 19:06:02 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201701011906.v01J62uX044566@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Sun, 1 Jan 2017 19:06:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r311016 - stable/11/sys/dev/sfxge/common X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Jan 2017 19:06:03 -0000 Author: arybchik Date: Sun Jan 1 19:06:02 2017 New Revision: 311016 URL: https://svnweb.freebsd.org/changeset/base/311016 Log: MFC r310746 sfxge(4): make the common code determine the number of PFs Submitted by: Ivan Malov Sponsored by: Solarflare Communications, Inc. Modified: stable/11/sys/dev/sfxge/common/ef10_nic.c stable/11/sys/dev/sfxge/common/efx.h stable/11/sys/dev/sfxge/common/siena_nic.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/sfxge/common/ef10_nic.c ============================================================================== --- stable/11/sys/dev/sfxge/common/ef10_nic.c Sun Jan 1 19:04:40 2017 (r311015) +++ stable/11/sys/dev/sfxge/common/ef10_nic.c Sun Jan 1 19:06:02 2017 (r311016) @@ -961,6 +961,50 @@ ef10_nic_pio_unlink( return (efx_mcdi_unlink_piobuf(enp, vi_index)); } +static __checkReturn efx_rc_t +ef10_mcdi_get_pf_count( + __in efx_nic_t *enp, + __out uint32_t *pf_countp) +{ + efx_mcdi_req_t req; + uint8_t payload[MAX(MC_CMD_GET_PF_COUNT_IN_LEN, + MC_CMD_GET_PF_COUNT_OUT_LEN)]; + efx_rc_t rc; + + (void) memset(payload, 0, sizeof (payload)); + req.emr_cmd = MC_CMD_GET_PF_COUNT; + req.emr_in_buf = payload; + req.emr_in_length = MC_CMD_GET_PF_COUNT_IN_LEN; + req.emr_out_buf = payload; + req.emr_out_length = MC_CMD_GET_PF_COUNT_OUT_LEN; + + efx_mcdi_execute(enp, &req); + + if (req.emr_rc != 0) { + rc = req.emr_rc; + goto fail1; + } + + if (req.emr_out_length_used < MC_CMD_GET_PF_COUNT_OUT_LEN) { + rc = EMSGSIZE; + goto fail2; + } + + *pf_countp = *MCDI_OUT(req, uint8_t, + MC_CMD_GET_PF_COUNT_OUT_PF_COUNT_OFST); + + EFSYS_ASSERT(*pf_countp != 0); + + return (0); + +fail2: + EFSYS_PROBE(fail2); +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + + return (rc); +} + __checkReturn efx_rc_t ef10_get_datapath_caps( __in efx_nic_t *enp) @@ -975,6 +1019,9 @@ ef10_get_datapath_caps( &tso2nc)) != 0) goto fail1; + if ((rc = ef10_mcdi_get_pf_count(enp, &encp->enc_hw_pf_count)) != 0) + goto fail1; + #define CAP_FLAG(flags1, field) \ ((flags1) & (1 << (MC_CMD_GET_CAPABILITIES_V2_OUT_ ## field ## _LBN))) Modified: stable/11/sys/dev/sfxge/common/efx.h ============================================================================== --- stable/11/sys/dev/sfxge/common/efx.h Sun Jan 1 19:04:40 2017 (r311015) +++ stable/11/sys/dev/sfxge/common/efx.h Sun Jan 1 19:06:02 2017 (r311016) @@ -1142,6 +1142,8 @@ typedef struct efx_nic_cfg_s { /* Number of TSO contexts on the NIC (FATSOv2) */ uint32_t enc_fw_assisted_tso_v2_n_contexts; boolean_t enc_hw_tx_insert_vlan_enabled; + /* Number of PFs on the NIC */ + uint32_t enc_hw_pf_count; /* Datapath firmware vadapter/vport/vswitch support */ boolean_t enc_datapath_cap_evb; boolean_t enc_rx_disable_scatter_supported; Modified: stable/11/sys/dev/sfxge/common/siena_nic.c ============================================================================== --- stable/11/sys/dev/sfxge/common/siena_nic.c Sun Jan 1 19:04:40 2017 (r311015) +++ stable/11/sys/dev/sfxge/common/siena_nic.c Sun Jan 1 19:06:02 2017 (r311016) @@ -105,6 +105,13 @@ siena_board_cfg( encp->enc_board_type = board_type; + /* + * There is no possibility to determine the number of PFs on Siena + * by issuing MCDI request, and it is not an easy task to find the + * value based on the board type, so 'enc_hw_pf_count' is set to 1 + */ + encp->enc_hw_pf_count = 1; + /* Additional capabilities */ encp->enc_clk_mult = 1; if (EFX_DWORD_FIELD(capabilities, MC_CMD_CAPABILITIES_TURBO)) {