lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: 
 <BY3PR18MB4737291987BDDC0B6DE88E13C6202@BY3PR18MB4737.namprd18.prod.outlook.com>
Date: Thu, 7 Mar 2024 10:33:26 +0000
From: Sunil Kovvuri Goutham <sgoutham@...vell.com>
To: Mengyuan Lou <mengyuanlou@...-swift.com>,
        "netdev@...r.kernel.org"
	<netdev@...r.kernel.org>
CC: "jiawenwu@...stnetic.com" <jiawenwu@...stnetic.com>
Subject: RE: [PATCH net-next 1/5] net: libwx: Add malibox api for wangxun pf
 drivers



> -----Original Message-----
> From: Mengyuan Lou <mengyuanlou@...-swift.com>
> Sent: Thursday, March 7, 2024 3:25 PM
> To: netdev@...r.kernel.org
> Cc: jiawenwu@...stnetic.com; Mengyuan Lou <mengyuanlou@...-swift.com>
> Subject: [EXTERNAL] [PATCH net-next 1/5] net: libwx: Add malibox api for
> wangxun pf drivers
> 
> Implements the mailbox interfaces for wangxun pf drivers ngbe and txgbe.
> 
> Signed-off-by: Mengyuan Lou <mengyuanlou@...-swift.com>
> ---
>  drivers/net/ethernet/wangxun/libwx/Makefile  |   2 +-
>  drivers/net/ethernet/wangxun/libwx/wx_mbx.c  | 190 +++++++++++++++++++
> drivers/net/ethernet/wangxun/libwx/wx_mbx.h  |  32 ++++
>  drivers/net/ethernet/wangxun/libwx/wx_type.h |   5 +
>  4 files changed, 228 insertions(+), 1 deletion(-)  create mode 100644
> drivers/net/ethernet/wangxun/libwx/wx_mbx.c
>  create mode 100644 drivers/net/ethernet/wangxun/libwx/wx_mbx.h
> 
> diff --git a/drivers/net/ethernet/wangxun/libwx/Makefile
> b/drivers/net/ethernet/wangxun/libwx/Makefile
> index 42ccd6e4052e..913a978c9032 100644
> --- a/drivers/net/ethernet/wangxun/libwx/Makefile
> +++ b/drivers/net/ethernet/wangxun/libwx/Makefile
> @@ -4,4 +4,4 @@
> 
>  obj-$(CONFIG_LIBWX) += libwx.o
> 
> -libwx-objs := wx_hw.o wx_lib.o wx_ethtool.o
> +libwx-objs := wx_hw.o wx_lib.o wx_ethtool.o wx_mbx.o
> diff --git a/drivers/net/ethernet/wangxun/libwx/wx_mbx.c
> b/drivers/net/ethernet/wangxun/libwx/wx_mbx.c
> new file mode 100644
> index 000000000000..5fbde79a5937
> --- /dev/null
> +++ b/drivers/net/ethernet/wangxun/libwx/wx_mbx.c
> @@ -0,0 +1,190 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Copyright (c) 2015 - 2024 Beijing WangXun Technology Co., Ltd. */
> +#include <linux/pci.h> #include "wx_type.h"
> +#include "wx_mbx.h"
> +
> +/**
> + *  wx_obtain_mbx_lock_pf - obtain mailbox lock
> + *  @wx: pointer to the HW structure
> + *  @vf: the VF index
> + *
> + *  return SUCCESS if we obtained the mailbox lock  **/ static int
> +wx_obtain_mbx_lock_pf(struct wx *wx, u16 vf) {
> +	int ret = -EBUSY;
> +	int count = 10;
> +	u32 mailbox;
> +
> +	while (count--) {
> +		/* Take ownership of the buffer */
> +		wr32(wx, WX_PXMAILBOX(vf), WX_PXMAILBOX_PFU);
> +
> +		/* reserve mailbox for vf use */
> +		mailbox = rd32(wx, WX_PXMAILBOX(vf));
> +		if (mailbox & WX_PXMAILBOX_PFU) {
> +			ret = 0;
> +			break;
> +		}
> +	}
> +
> +	if (ret)
> +		wx_err(wx, "Failed to obtain mailbox lock for PF%d", vf);
> +
> +	return ret;

Even though error is returned here, rest of the patches seems to always assume that locking
is successful. Return value not checked.
If getting lock is essential, it may be better to convert this into poll + yield with delay instead of busy poll of 10 times.



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ