From owner-svn-src-all@freebsd.org Thu May 16 15:41:06 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 93656159A7D1; Thu, 16 May 2019 15:41:06 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 35E878409F; Thu, 16 May 2019 15:41:06 +0000 (UTC) (envelope-from hselasky@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 122AA22CE6; Thu, 16 May 2019 15:41:06 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4GFf5OY041728; Thu, 16 May 2019 15:41:05 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4GFf53l041723; Thu, 16 May 2019 15:41:05 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201905161541.x4GFf53l041723@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 16 May 2019 15:41:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347711 - in stable/12/sys/dev/mlx5: . mlx5_fpga mlx5_fpga_tools X-SVN-Group: stable-12 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in stable/12/sys/dev/mlx5: . mlx5_fpga mlx5_fpga_tools X-SVN-Commit-Revision: 347711 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 35E878409F X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.96)[-0.960,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 May 2019 15:41:06 -0000 Author: hselasky Date: Thu May 16 15:41:04 2019 New Revision: 347711 URL: https://svnweb.freebsd.org/changeset/base/347711 Log: MFC r347247: Add MLX5_FPGA_RELOAD IOCTL(2) to mlx5fpga. Submitted by: kib@ Sponsored by: Mellanox Technologies Modified: stable/12/sys/dev/mlx5/mlx5_fpga/mlx5_ifc_fpga.h stable/12/sys/dev/mlx5/mlx5_fpga/mlx5fpga_sdk.c stable/12/sys/dev/mlx5/mlx5_fpga_tools/mlx5fpga_tools_char.c stable/12/sys/dev/mlx5/mlx5io.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/mlx5/mlx5_fpga/mlx5_ifc_fpga.h ============================================================================== --- stable/12/sys/dev/mlx5/mlx5_fpga/mlx5_ifc_fpga.h Thu May 16 15:40:22 2019 (r347710) +++ stable/12/sys/dev/mlx5/mlx5_fpga/mlx5_ifc_fpga.h Thu May 16 15:41:04 2019 (r347711) @@ -135,6 +135,7 @@ enum { MLX5_FPGA_CTRL_OPERATION_RESET_SANDBOX = 0x6, MLX5_FPGA_CTRL_OPERATION_DISCONNECT = 0x9, MLX5_FPGA_CTRL_OPERATION_CONNECT = 0xA, + MLX5_FPGA_CTRL_OPERATION_RELOAD = 0xB, }; struct mlx5_ifc_fpga_ctrl_bits { Modified: stable/12/sys/dev/mlx5/mlx5_fpga/mlx5fpga_sdk.c ============================================================================== --- stable/12/sys/dev/mlx5/mlx5_fpga/mlx5fpga_sdk.c Thu May 16 15:40:22 2019 (r347710) +++ stable/12/sys/dev/mlx5/mlx5_fpga/mlx5fpga_sdk.c Thu May 16 15:41:04 2019 (r347711) @@ -324,6 +324,45 @@ void mlx5_fpga_device_query(struct mlx5_fpga_device *f } EXPORT_SYMBOL(mlx5_fpga_device_query); +static int mlx5_fpga_device_reload_cmd(struct mlx5_fpga_device *fdev) +{ + struct mlx5_core_dev *mdev = fdev->mdev; + unsigned long timeout; + unsigned long flags; + int err = 0; + + mlx5_fpga_info(fdev, "mlx5/fpga - reload started\n"); + fdev->fdev_state = MLX5_FDEV_STATE_IN_PROGRESS; + reinit_completion(&fdev->load_event); + err = mlx5_fpga_ctrl_op(mdev, MLX5_FPGA_CTRL_OPERATION_RELOAD); + if (err) { + mlx5_fpga_err(fdev, "Failed to request reload: %d\n", + err); + goto out; + } + timeout = jiffies + msecs_to_jiffies(MLX5_FPGA_LOAD_TIMEOUT); + err = wait_for_completion_timeout(&fdev->load_event, + timeout - jiffies); + if (err < 0) { + mlx5_fpga_err(fdev, "Failed waiting for reload: %d\n", err); + fdev->fdev_state = MLX5_FDEV_STATE_FAILURE; + goto out; + } + /* Check device loaded successful */ + err = mlx5_fpga_device_start(mdev); + if (err) { + mlx5_fpga_err(fdev, "Failed load check for reload: %d\n", err); + fdev->fdev_state = MLX5_FDEV_STATE_FAILURE; + goto out; + } + spin_lock_irqsave(&fdev->state_lock, flags); + fdev->fdev_state = MLX5_FDEV_STATE_SUCCESS; + spin_unlock_irqrestore(&fdev->state_lock, flags); + mlx5_fpga_info(fdev, "mlx5/fpga - reload ended\n"); +out: + return err; +} + int mlx5_fpga_device_reload(struct mlx5_fpga_device *fdev, enum mlx5_fpga_image image) { @@ -350,6 +389,12 @@ int mlx5_fpga_device_reload(struct mlx5_fpga_device *f return err; mutex_lock(&mdev->intf_state_mutex); + + if (image == MLX5_FPGA_IMAGE_RELOAD) { + err = mlx5_fpga_device_reload_cmd(fdev); + goto out; + } + clear_bit(MLX5_INTERFACE_STATE_UP, &mdev->intf_state); mlx5_unregister_device(mdev); @@ -359,7 +404,7 @@ int mlx5_fpga_device_reload(struct mlx5_fpga_device *f fdev->fdev_state = MLX5_FDEV_STATE_IN_PROGRESS; reinit_completion(&fdev->load_event); - if (image <= MLX5_FPGA_IMAGE_MAX) { + if (image <= MLX5_FPGA_IMAGE_FACTORY) { mlx5_fpga_info(fdev, "Loading from flash\n"); err = mlx5_fpga_load(mdev, image); if (err) { @@ -367,7 +412,7 @@ int mlx5_fpga_device_reload(struct mlx5_fpga_device *f err); goto out; } - } else { + } else if (image == MLX5_FPGA_IMAGE_RESET) { mlx5_fpga_info(fdev, "Resetting\n"); err = mlx5_fpga_ctrl_op(mdev, MLX5_FPGA_CTRL_OPERATION_RESET); if (err) { @@ -375,6 +420,10 @@ int mlx5_fpga_device_reload(struct mlx5_fpga_device *f err); goto out; } + } else { + mlx5_fpga_err(fdev, "Unknown command: %d\n", + image); + goto out; } timeout = jiffies + msecs_to_jiffies(MLX5_FPGA_LOAD_TIMEOUT); Modified: stable/12/sys/dev/mlx5/mlx5_fpga_tools/mlx5fpga_tools_char.c ============================================================================== --- stable/12/sys/dev/mlx5/mlx5_fpga_tools/mlx5fpga_tools_char.c Thu May 16 15:40:22 2019 (r347710) +++ stable/12/sys/dev/mlx5/mlx5_fpga_tools/mlx5fpga_tools_char.c Thu May 16 15:41:04 2019 (r347711) @@ -225,7 +225,7 @@ tools_char_ioctl(struct cdev *dev, u_long cmd, caddr_t break; case MLX5_FPGA_LOAD: arg = *(int *)data; - if (arg > MLX5_FPGA_IMAGE_MAX) { + if (arg > MLX5_FPGA_IMAGE_FACTORY) { dev_err(mlx5_fpga_dev(fdev), "unknown image type %u\n", arg); err = EINVAL; @@ -234,11 +234,14 @@ tools_char_ioctl(struct cdev *dev, u_long cmd, caddr_t err = mlx5_fpga_device_reload(fdev, arg); break; case MLX5_FPGA_RESET: - err = mlx5_fpga_device_reload(fdev, MLX5_FPGA_IMAGE_MAX + 1); + err = mlx5_fpga_device_reload(fdev, MLX5_FPGA_IMAGE_RESET); break; + case MLX5_FPGA_RELOAD: + err = mlx5_fpga_device_reload(fdev, MLX5_FPGA_IMAGE_RELOAD); + break; case MLX5_FPGA_IMAGE_SEL: arg = *(int *)data; - if (arg > MLX5_FPGA_IMAGE_MAX) { + if (arg > MLX5_FPGA_IMAGE_FACTORY) { dev_err(mlx5_fpga_dev(fdev), "unknown image type %u\n", arg); err = EINVAL; Modified: stable/12/sys/dev/mlx5/mlx5io.h ============================================================================== --- stable/12/sys/dev/mlx5/mlx5io.h Thu May 16 15:40:22 2019 (r347710) +++ stable/12/sys/dev/mlx5/mlx5io.h Thu May 16 15:41:04 2019 (r347711) @@ -67,8 +67,9 @@ enum mlx5_fpga_id { enum mlx5_fpga_image { MLX5_FPGA_IMAGE_USER = 0, MLX5_FPGA_IMAGE_FACTORY = 1, - MLX5_FPGA_IMAGE_MAX = MLX5_FPGA_IMAGE_FACTORY, MLX5_FPGA_IMAGE_FACTORY_FAILOVER = 2, + MLX5_FPGA_IMAGE_RESET = 17, + MLX5_FPGA_IMAGE_RELOAD = 18, }; enum mlx5_fpga_status { @@ -135,6 +136,7 @@ struct mlx5_fpga_temperature { #define MLX5_FPGA_CAP _IOR('m', 0x85, uint32_t[MLX5_FPGA_CAP_ARR_SZ]) #define MLX5_FPGA_TEMPERATURE _IOWR('m', 0x86, struct mlx5_fpga_temperature) #define MLX5_FPGA_CONNECT _IOWR('m', 0x87, enum mlx5_fpga_connect) +#define MLX5_FPGA_RELOAD _IO('m', 0x88) #define MLX5_FPGA_TOOLS_NAME_SUFFIX "_mlx5_fpga_tools"