From patchwork Tue Aug 15 17:08:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dupuis, Chad" X-Patchwork-Id: 9902217 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E059E60230 for ; Tue, 15 Aug 2017 17:08:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAF732888C for ; Tue, 15 Aug 2017 17:08:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF32A288AD; Tue, 15 Aug 2017 17:08:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E43AD2888C for ; Tue, 15 Aug 2017 17:08:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752487AbdHORIt (ORCPT ); Tue, 15 Aug 2017 13:08:49 -0400 Received: from mail-bl2nam02on0080.outbound.protection.outlook.com ([104.47.38.80]:26992 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751702AbdHORIs (ORCPT ); Tue, 15 Aug 2017 13:08:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=TAkiEiQM6gKzTUDLJqqql3GpSJ3531za4OoatSdT0Gg=; b=kXkXxbAqvNtr1yglzNhX21K8EV7YHf2RGa5JGkWdaspZ28MloewZ5DLU34bsAa+u3lBYb083aq6m/XfodBnpvw5fybKWsFibpNJtDpO0+2ZjxmCHxM6jfwysPOGdQ8nKOF1zoibpTvyWAJH37btTxcS9FOgO6OeLtCLpps4DPmQ= Received: from BY2PR07CA0092.namprd07.prod.outlook.com (10.166.107.45) by BN6PR07MB3441.namprd07.prod.outlook.com (10.161.153.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1341.21; Tue, 15 Aug 2017 17:08:46 +0000 Received: from BN1AFFO11FD017.protection.gbl (2a01:111:f400:7c10::199) by BY2PR07CA0092.outlook.office365.com (2a01:111:e400:7bff::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1341.21 via Frontend Transport; Tue, 15 Aug 2017 17:08:46 +0000 Authentication-Results: spf=none (sender IP is 50.232.66.26) smtp.mailfrom=cavium.com; oracle.com; dkim=none (message not signed) header.d=none; oracle.com; dmarc=none action=none header.from=cavium.com; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BN1AFFO11FD017.mail.protection.outlook.com (10.58.52.77) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.1304.16 via Frontend Transport; Tue, 15 Aug 2017 17:08:44 +0000 Received: from dut1171.mv.qlogic.com (172.29.51.171) by CAEXCH02.caveonetworks.com (10.17.4.29) with Microsoft SMTP Server id 14.2.347.0; Tue, 15 Aug 2017 10:08:22 -0700 Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id v7FH8MAC020849; Tue, 15 Aug 2017 10:08:22 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id v7FH8MXk020848; Tue, 15 Aug 2017 10:08:22 -0700 From: Chad Dupuis To: CC: , , Subject: [PATCH 2/6] qedf: Use granted MAC from the FCF for the FCoE source address if it is available. Date: Tue, 15 Aug 2017 10:08:17 -0700 Message-ID: <20170815170821.20806-3-chad.dupuis@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170815170821.20806-1-chad.dupuis@cavium.com> References: <20170815170821.20806-1-chad.dupuis@cavium.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:50.232.66.26; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(428002)(189002)(199003)(478600001)(50986999)(76176999)(54906002)(36756003)(356003)(110136004)(305945005)(107886003)(8676002)(69596002)(106466001)(189998001)(72206003)(42186005)(626005)(80596001)(2351001)(101416001)(33646002)(5660300001)(4326008)(105586002)(1076002)(50466002)(5003940100001)(86362001)(6666003)(575784001)(6916009)(2950100002)(81166006)(81156014)(2906002)(8936002)(48376002)(87636003)(50226002)(47776003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR07MB3441; H:CAEXCH02.caveonetworks.com; FPR:; SPF:None; PTR:50-232-66-26-static.hfc.comcastbusiness.net; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD017; 1:ik25WYu9xegFxzFF71N6UAsA14htnfn2OzwJvXD3hT4eeIzYKa0Z6USBfhf+wtFAfkm94YLoAjI0m9CGM6tdTsfvZVcIRPfO8MzJ6mJjxfx+kawpNw235yXbcLafLK+HLaXRKvCENyVNaez7ikzV724mzn3RjI+2zVBvmOyLPv0u6TD4pMIJpuxp2h3npLDaYI1kXGzMKMyKuz39pN2+AbVAoie5zAvx2gUpYciC28CkEaNKbBMm+XhQMtbvYyaWI3MCWB4aCClFTwZgQdJHZvCQtqHDRw8q3HZ8Iw11MHGJ9F+o0WRnsiXbUMFW31lwDZkL+v4GFg66J9Ia8r92PsDTr6qHVEpZlhgoK4994ioppl2Pa/T6tcaAE0VRiQz6GZtxNA0Qhk8hMaQyb+IsYBPqSD9wGglqqF7pjp+ufQGAzy4G05Q8wc4dQpSBeKsPdlnPt4Ox7BGv6L/Cn1DCXjtKv5mIByyoZK3VlvE/8Ep/vUGcTs/Ym83XmGXb8UeZtTsd+28CQ0pAUlHxOCzqlj+OFXOG+Om47iwQ7E/HdnNvNW6d3Nn0E6+p8SpnAfTQsj6DpU4gQL7xeXZCum9FTRXsg5NrZDbKQXZIhHhaTgzqIJZv+j0aulhOCzbat+Dmik2u6K3Fc3T0j9o4kgeQU9srMl8aagYebNympy0tJFmZxmOx0hV6+UG0KllPBgDNlYZHMDqqF66s+9/pScfLUngqViDs22Pp9objG/rhyMyeZLBg2RNKIanFXY0WWQLjxAMjjE8ndN5vRHwslZsExWIOcwodarrok8OrnguS2jQ= X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: adda7af3-5974-403d-dd5f-08d4e40049e4 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:BN6PR07MB3441; X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3441; 3:H12aNe4u7q1/TXyypFagil8IqS7/9eTdjkJLToKfQsijWcXdfcrVY+RbJ/fuTUbtsqiNxubeesvG1Wq5tVG9yBWBTFHMgRmYow0bEhXTyZgClTsO167F66C70c5s2rtZZqO2VWN5BTPFOpa7p+yqiO2GDC7i8Xcl+oTRaeJZ/fvoLmBlhotq8nfD+bUNMShZdIc3B5zGYH40D8pQ7XNfwi3rYyKZ8yQpeetiKPyf1Cn0rPIU84M27CkbJLQZlPz3WO6Qkx9vWcJuC1UO9WMpn4dfR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3VdjKbLhID1p5sEWL06gCAD3iTr59XPOtMtFS64YHYRy/A5V8NfgE5ixN6QoXXHwX17cRh+NFZEEpxvcqGc12gOkMIDeqRPe/eXK2glTcRaM8VD3UzoEblou6e0Mht80apfjF0NE1xjJqOzjnyyNEm1j; 4:HWir8GQWkgTkhSbVnBahfmGYB7X9HI8jOW8m+dY7iXhikGfvYx01RIlpx5o/f0N+2zC/BNx5kxB8NZU3rykeqOhTAy+PM9iPM+qSMW8kokNjktn7ZwlEHDBzzMjnNgQ3kPsrUJc/LiI/0K0jfWvoOSd9PwOg0ANUoAtKB5cGgqcZUc76fFpdaPYw0ckasPOhNgc6eO/mzpY+iQ1KZmbeKBQ5ldEqjP9H9bOT+VKaRa6jAw293D4M3d36o/a0JrJe X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(13016025)(13018025)(8121501046)(3002001)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(20161123564025)(20161123555025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN6PR07MB3441; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN6PR07MB3441; X-Forefront-PRVS: 04004D94E2 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR07MB3441; 23:Wt/0GEH45gKRS24E7aY5btLOvdyIoskzIuL58EljO?= =?us-ascii?Q?yGRL5ntHq7frR00Onci7jVO0PSMQRDkucCy9O4l41X/gFRSWnguTnXCsevEN?= =?us-ascii?Q?3uqF0rQ1V1bevbUVt5fb8h/rSCmNYF3Yfvdd96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WkomA0tQsVoIbWCkVnskhSt+sNrKX9X+6c0XZz14FwHN74?= =?us-ascii?Q?TFglFA=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3441; 6:ORQ0YK1d8R+hB/klDZ/YcjgyYIgssNufn3Y4Nt6mOCUMPhGZtb6QvnrGdilsEyLC1EJOT855ki57yDmieLoc6322VcwjOXQIoSZYO1FEnw6jv64d7rDqkqKsgACa2v8SLG6MkLEbqsPo9nApbyMRzblI3UdV+md8h+zfXwnS8MVa0mnS7JAGga2UFTjqEvBipOvO83mFwYymWBl+8gvKT1Um+wVLrx91hC7GcdH7eX1Lz0RlS/Wr1tkEZpJMFtj4rHYXfOXmhuHIRESStmiu+cmaQga0L3dJuysb2gUbRR94ncFXvmuS0ZZlxnf+qC9/FDA9k/59DnLa1avAdzt/iw==; 5:IFDa8vhB67daR4akWNNedxDWA4AIQPwmBwPeZcMWtbV4EzuU5PFjmYdv8Zcavm99JUSSo4wMRm8PvHuJ5bbC2fWl+uUmNqnxbwuDvIyXetcbN+HqiAgq5iIDAwCC8K6/qu0sHxKnycWp4EoTT/Q7I7MKtM+40DXayy+JzTcZR5U=; 24:5FczyLWOuhErqRYw1iaF1W30pIFwXvkJFQ9qSHqclWTUkwgLcEBI+ypFrx/P1J8l9HkdPojbdbLe3LXG4RJpdttBMmf30iNkL2IdKEO8ls8=; 7:hdFkfq5CtfnuqIv1k8HyB9cNcjcIq5vMH0Nw4xBeD5AKMa3PlxqecdiwaEnNcAR0SL5suFYiKulnabmqm7W8qmNI56mat6yqeE0nMjjHAWhzizff7P/CjHaiVe1r0bmKbFiJ2O9gEdf4cPRmFkR66/9pHuDdjJWZPER/MS3ckW39H4IanW1VJeOLj2WNoj6Byc4Pq/OwkXu4H3P29iR6CFuqCK3O9kVb2X1U6FjY+Gg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2017 17:08:44.5563 (UTC) X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=711e4ccf-2e9b-4bcf-a551-4094005b6194; Ip=[50.232.66.26]; Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB3441 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently in the driver we've been using the fc_fcoe_set_mac() function to set the source MAC for FCoE traffic. This works well in most cases as it uses the spec. default FCF-MAC. However, if the administrator changes the FCF-MAC switch, then any FCoE traffic we send will be dropped by the switch. Instead we should check the granted MAC from the FLOGI payload and use that address if it is present. Otherwise, fall back to using the the default FCF-MAC and the fabric ID of the port as the FCoE MAC address. Once this address is known we need to set it when doing non-offload traffic, offload traffic and setting the data_src_address libfcoe uses for FIP keep alive messages. Signed-off-by: Chad Dupuis --- drivers/scsi/qedf/qedf.h | 1 - drivers/scsi/qedf/qedf_fip.c | 17 ------------- drivers/scsi/qedf/qedf_main.c | 59 +++++++++++++++++++++++++++++++++++++------ 3 files changed, 51 insertions(+), 26 deletions(-) diff --git a/drivers/scsi/qedf/qedf.h b/drivers/scsi/qedf/qedf.h index 351f06dfc5a0..e05ec331557b 100644 --- a/drivers/scsi/qedf/qedf.h +++ b/drivers/scsi/qedf/qedf.h @@ -443,7 +443,6 @@ extern void qedf_cmd_mgr_free(struct qedf_cmd_mgr *cmgr); extern int qedf_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc_cmd); extern void qedf_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb); -extern void qedf_update_src_mac(struct fc_lport *lport, u8 *addr); extern u8 *qedf_get_src_mac(struct fc_lport *lport); extern void qedf_fip_recv(struct qedf_ctx *qedf, struct sk_buff *skb); extern void qedf_fcoe_send_vlan_req(struct qedf_ctx *qedf); diff --git a/drivers/scsi/qedf/qedf_fip.c b/drivers/scsi/qedf/qedf_fip.c index aefd24ca9604..28ce0f7ffc7b 100644 --- a/drivers/scsi/qedf/qedf_fip.c +++ b/drivers/scsi/qedf/qedf_fip.c @@ -242,26 +242,9 @@ void qedf_fip_recv(struct qedf_ctx *qedf, struct sk_buff *skb) } } -void qedf_update_src_mac(struct fc_lport *lport, u8 *addr) -{ - struct qedf_ctx *qedf = lport_priv(lport); - - QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC, - "Setting data_src_addr=%pM.\n", addr); - ether_addr_copy(qedf->data_src_addr, addr); -} - u8 *qedf_get_src_mac(struct fc_lport *lport) { - u8 mac[ETH_ALEN]; - u8 port_id[3]; struct qedf_ctx *qedf = lport_priv(lport); - /* We need to use the lport port_id to create the data_src_addr */ - if (is_zero_ether_addr(qedf->data_src_addr)) { - hton24(port_id, lport->port_id); - fc_fcoe_set_mac(mac, port_id); - qedf->ctlr.update_mac(lport, mac); - } return qedf->data_src_addr; } diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index 9744b6aa2a03..1df80aa03da1 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -187,6 +188,50 @@ static void qedf_handle_link_update(struct work_struct *work) } } +#define QEDF_FCOE_MAC_METHOD_GRANGED_MAC 1 +#define QEDF_FCOE_MAC_METHOD_FCF_MAP 2 +#define QEDF_FCOE_MAC_METHOD_FCOE_SET_MAC 3 +static void qedf_set_data_src_addr(struct qedf_ctx *qedf, struct fc_frame *fp) +{ + u8 *granted_mac; + struct fc_frame_header *fh = fc_frame_header_get(fp); + u8 fc_map[3]; + int method = 0; + + /* Get granted MAC address from FIP FLOGI payload */ + granted_mac = fr_cb(fp)->granted_mac; + + /* + * We set the source MAC for FCoE traffic based on the Granted MAC + * address from the switch. + * + * If granted_mac is non-zero, we used that. + * If the granted_mac is zeroed out, created the FCoE MAC based on + * the sel_fcf->fc_map and the d_id fo the FLOGI frame. + * If sel_fcf->fc_map is 0 then we use the default FCF-MAC plus the + * d_id of the FLOGI frame. + */ + if (!is_zero_ether_addr(granted_mac)) { + ether_addr_copy(qedf->data_src_addr, granted_mac); + method = QEDF_FCOE_MAC_METHOD_GRANGED_MAC; + } else if (qedf->ctlr.sel_fcf->fc_map != 0) { + hton24(fc_map, qedf->ctlr.sel_fcf->fc_map); + qedf->data_src_addr[0] = fc_map[0]; + qedf->data_src_addr[1] = fc_map[1]; + qedf->data_src_addr[2] = fc_map[2]; + qedf->data_src_addr[3] = fh->fh_d_id[0]; + qedf->data_src_addr[4] = fh->fh_d_id[1]; + qedf->data_src_addr[5] = fh->fh_d_id[2]; + method = QEDF_FCOE_MAC_METHOD_FCF_MAP; + } else { + fc_fcoe_set_mac(qedf->data_src_addr, fh->fh_d_id); + method = QEDF_FCOE_MAC_METHOD_FCOE_SET_MAC; + } + + QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC, + "QEDF data_src_mac=%pM method=%d.\n", qedf->data_src_addr, method); +} + static void qedf_flogi_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg) { @@ -212,6 +257,10 @@ static void qedf_flogi_resp(struct fc_seq *seq, struct fc_frame *fp, /* Log stats for FLOGI reject */ if (fc_frame_payload_op(fp) == ELS_LS_RJT) qedf->flogi_failed++; + else if (fc_frame_payload_op(fp) == ELS_LS_ACC) { + /* Set the source MAC we will use for FCoE traffic */ + qedf_set_data_src_addr(qedf, fp); + } /* Complete flogi_compl so we can proceed to sending ADISCs */ complete(&qedf->flogi_compl); @@ -927,7 +976,7 @@ static int qedf_xmit(struct fc_lport *lport, struct fc_frame *fp) ether_addr_copy(eh->h_dest, qedf->ctlr.dest_addr); /* Set the source MAC address */ - fc_fcoe_set_mac(eh->h_source, fh->fh_s_id); + ether_addr_copy(eh->h_source, qedf->data_src_addr); hp = (struct fcoe_hdr *)(eh + 1); memset(hp, 0, sizeof(*hp)); @@ -1025,7 +1074,6 @@ static int qedf_offload_connection(struct qedf_ctx *qedf, { struct qed_fcoe_params_offload conn_info; u32 port_id; - u8 lport_src_id[3]; int rval; uint16_t total_sqe = (fcport->sq_mem_size / sizeof(struct fcoe_wqe)); @@ -1054,11 +1102,7 @@ static int qedf_offload_connection(struct qedf_ctx *qedf, (dma_addr_t)(*(u64 *)(fcport->sq_pbl + 8)); /* Need to use our FCoE MAC for the offload session */ - port_id = fc_host_port_id(qedf->lport->host); - lport_src_id[2] = (port_id & 0x000000FF); - lport_src_id[1] = (port_id & 0x0000FF00) >> 8; - lport_src_id[0] = (port_id & 0x00FF0000) >> 16; - fc_fcoe_set_mac(conn_info.src_mac, lport_src_id); + ether_addr_copy(conn_info.src_mac, qedf->data_src_addr); ether_addr_copy(conn_info.dst_mac, qedf->ctlr.dest_addr); @@ -1347,7 +1391,6 @@ static void qedf_fcoe_ctlr_setup(struct qedf_ctx *qedf) fcoe_ctlr_init(&qedf->ctlr, FIP_ST_AUTO); qedf->ctlr.send = qedf_fip_send; - qedf->ctlr.update_mac = qedf_update_src_mac; qedf->ctlr.get_src_addr = qedf_get_src_mac; ether_addr_copy(qedf->ctlr.ctl_src_addr, qedf->mac); }