From patchwork Tue Jun 2 18:00:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksey Makarov X-Patchwork-Id: 479657 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 8D9F2140FDF for ; Wed, 3 Jun 2015 04:03:01 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932422AbbFBSBg (ORCPT ); Tue, 2 Jun 2015 14:01:36 -0400 Received: from mail-by2on0088.outbound.protection.outlook.com ([207.46.100.88]:34880 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1759904AbbFBSBJ (ORCPT ); Tue, 2 Jun 2015 14:01:09 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Aleksey.Makarov@caviumnetworks.com; Received: from hippophae.localdomain (64.2.3.194) by CO2PR0701MB823.namprd07.prod.outlook.com (10.141.247.11) with Microsoft SMTP Server (TLS) id 15.1.172.22; Tue, 2 Jun 2015 18:01:06 +0000 From: Aleksey Makarov To: CC: , , David Daney , Robert Richter , Aleksey Makarov , Sunil Goutham , Robert Richter Subject: [PATCH 03/10] net: thunderx: introduce a function for mailbox access Date: Tue, 2 Jun 2015 11:00:20 -0700 Message-ID: <1433268028-23992-4-git-send-email-aleksey.makarov@caviumnetworks.com> X-Mailer: git-send-email 2.4.1 In-Reply-To: <1433268028-23992-1-git-send-email-aleksey.makarov@caviumnetworks.com> References: <1433268028-23992-1-git-send-email-aleksey.makarov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [64.2.3.194] X-ClientProxiedBy: SN1PR18CA0005.namprd18.prod.outlook.com (25.163.219.143) To CO2PR0701MB823.namprd07.prod.outlook.com (10.141.247.11) X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CO2PR0701MB823; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(520003)(3002001); SRVR:CO2PR0701MB823; BCL:0; PCL:0; RULEID:; SRVR:CO2PR0701MB823; X-Forefront-PRVS: 05954A7C45 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(229853001)(48376002)(46102003)(122386002)(5001830100001)(19580395003)(19580405001)(2351001)(36756003)(81156007)(47776003)(66066001)(189998001)(50226001)(101416001)(4001540100001)(5001960100002)(64706001)(106356001)(50986999)(97736004)(50466002)(33646002)(5001860100001)(77156002)(40100003)(105586002)(76176999)(86362001)(5001920100001)(77096005)(2950100001)(62966003)(87976001)(92566002)(68736005)(42186005)(110136002); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR0701MB823; H:hippophae.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2015 18:01:06.0332 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR0701MB823 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This fixes sparse message: drivers/net/ethernet/cavium/thunder/nicvf_main.c:153:25: sparse: cast to restricted __le64 Reported-by: kbuild test robot Signed-off-by: Aleksey Makarov --- drivers/net/ethernet/cavium/thunder/nicvf_main.c | 27 +++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c index f81182c..989f005 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c @@ -110,17 +110,23 @@ u64 nicvf_queue_reg_read(struct nicvf *nic, u64 offset, u64 qidx) /* VF -> PF mailbox communication */ +static void nicvf_write_to_mbx(struct nicvf *nic, union nic_mbx *mbx) +{ + u64 *msg = (u64 *)mbx; + + nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 0, msg[0]); + nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 8, msg[1]); +} + int nicvf_send_msg_to_pf(struct nicvf *nic, union nic_mbx *mbx) { int timeout = NIC_MBOX_MSG_TIMEOUT; int sleep = 10; - u64 *msg = (u64 *)mbx; nic->pf_acked = false; nic->pf_nacked = false; - nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 0, msg[0]); - nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 8, msg[1]); + nicvf_write_to_mbx(nic, mbx); /* Wait for previous message to be acked, timeout 2sec */ while (!nic->pf_acked) { @@ -146,12 +152,13 @@ int nicvf_send_msg_to_pf(struct nicvf *nic, union nic_mbx *mbx) static int nicvf_check_pf_ready(struct nicvf *nic) { int timeout = 5000, sleep = 20; + union nic_mbx mbx = {}; + + mbx.msg.msg = NIC_MBOX_MSG_READY; nic->pf_ready_to_rcv_msg = false; - nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 0, - le64_to_cpu(NIC_MBOX_MSG_READY)); - nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 8, 1ULL); + nicvf_write_to_mbx(nic, &mbx); while (!nic->pf_ready_to_rcv_msg) { msleep(sleep); @@ -368,7 +375,9 @@ int nicvf_set_real_num_queues(struct net_device *netdev, static int nicvf_init_resources(struct nicvf *nic) { int err; - u64 mbx_addr = NIC_VF_PF_MAILBOX_0_1; + union nic_mbx mbx = {}; + + mbx.msg.msg = NIC_MBOX_MSG_CFG_DONE; /* Enable Qset */ nicvf_qset_config(nic, true); @@ -382,9 +391,7 @@ static int nicvf_init_resources(struct nicvf *nic) } /* Send VF config done msg to PF */ - nicvf_reg_write(nic, mbx_addr, le64_to_cpu(NIC_MBOX_MSG_CFG_DONE)); - mbx_addr += (NIC_PF_VF_MAILBOX_SIZE - 1) * 8; - nicvf_reg_write(nic, mbx_addr, 1ULL); + nicvf_write_to_mbx(nic, &mbx); return 0; }