Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2017, Mellanox Technologies, Ltd.  All rights reserved.
0003  *
0004  * This software is available to you under a choice of one of two
0005  * licenses.  You may choose to be licensed under the terms of the GNU
0006  * General Public License (GPL) Version 2, available from the file
0007  * COPYING in the main directory of this source tree, or the
0008  * OpenIB.org BSD license below:
0009  *
0010  *     Redistribution and use in source and binary forms, with or
0011  *     without modification, are permitted provided that the following
0012  *     conditions are met:
0013  *
0014  *      - Redistributions of source code must retain the above
0015  *        copyright notice, this list of conditions and the following
0016  *        disclaimer.
0017  *
0018  *      - Redistributions in binary form must reproduce the above
0019  *        copyright notice, this list of conditions and the following
0020  *        disclaimer in the documentation and/or other materials
0021  *        provided with the distribution.
0022  *
0023  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0024  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0025  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0026  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
0027  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
0028  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0029  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0030  * SOFTWARE.
0031  */
0032 
0033 #ifndef __LIB_MLX5_H__
0034 #define __LIB_MLX5_H__
0035 
0036 #include "mlx5_core.h"
0037 
0038 void mlx5_init_reserved_gids(struct mlx5_core_dev *dev);
0039 void mlx5_cleanup_reserved_gids(struct mlx5_core_dev *dev);
0040 int  mlx5_core_reserve_gids(struct mlx5_core_dev *dev, unsigned int count);
0041 void mlx5_core_unreserve_gids(struct mlx5_core_dev *dev, unsigned int count);
0042 int  mlx5_core_reserved_gid_alloc(struct mlx5_core_dev *dev, int *gid_index);
0043 void mlx5_core_reserved_gid_free(struct mlx5_core_dev *dev, int gid_index);
0044 int mlx5_crdump_enable(struct mlx5_core_dev *dev);
0045 void mlx5_crdump_disable(struct mlx5_core_dev *dev);
0046 int mlx5_crdump_collect(struct mlx5_core_dev *dev, u32 *cr_data);
0047 
0048 /* TODO move to lib/events.h */
0049 
0050 #define PORT_MODULE_EVENT_MODULE_STATUS_MASK 0xF
0051 #define PORT_MODULE_EVENT_ERROR_TYPE_MASK    0xF
0052 
0053 enum port_module_event_status_type {
0054     MLX5_MODULE_STATUS_PLUGGED   = 0x1,
0055     MLX5_MODULE_STATUS_UNPLUGGED = 0x2,
0056     MLX5_MODULE_STATUS_ERROR     = 0x3,
0057     MLX5_MODULE_STATUS_DISABLED  = 0x4,
0058     MLX5_MODULE_STATUS_NUM,
0059 };
0060 
0061 enum  port_module_event_error_type {
0062     MLX5_MODULE_EVENT_ERROR_POWER_BUDGET_EXCEEDED    = 0x0,
0063     MLX5_MODULE_EVENT_ERROR_LONG_RANGE_FOR_NON_MLNX  = 0x1,
0064     MLX5_MODULE_EVENT_ERROR_BUS_STUCK                = 0x2,
0065     MLX5_MODULE_EVENT_ERROR_NO_EEPROM_RETRY_TIMEOUT  = 0x3,
0066     MLX5_MODULE_EVENT_ERROR_ENFORCE_PART_NUMBER_LIST = 0x4,
0067     MLX5_MODULE_EVENT_ERROR_UNKNOWN_IDENTIFIER       = 0x5,
0068     MLX5_MODULE_EVENT_ERROR_HIGH_TEMPERATURE         = 0x6,
0069     MLX5_MODULE_EVENT_ERROR_BAD_CABLE                = 0x7,
0070     MLX5_MODULE_EVENT_ERROR_PCIE_POWER_SLOT_EXCEEDED = 0xc,
0071     MLX5_MODULE_EVENT_ERROR_NUM,
0072 };
0073 
0074 struct mlx5_pme_stats {
0075     u64 status_counters[MLX5_MODULE_STATUS_NUM];
0076     u64 error_counters[MLX5_MODULE_EVENT_ERROR_NUM];
0077 };
0078 
0079 void mlx5_get_pme_stats(struct mlx5_core_dev *dev, struct mlx5_pme_stats *stats);
0080 int mlx5_notifier_call_chain(struct mlx5_events *events, unsigned int event, void *data);
0081 
0082 /* Crypto */
0083 enum {
0084     MLX5_ACCEL_OBJ_TLS_KEY = MLX5_GENERAL_OBJECT_TYPE_ENCRYPTION_KEY_TYPE_TLS,
0085     MLX5_ACCEL_OBJ_IPSEC_KEY = MLX5_GENERAL_OBJECT_TYPE_ENCRYPTION_KEY_TYPE_IPSEC,
0086 };
0087 
0088 int mlx5_create_encryption_key(struct mlx5_core_dev *mdev,
0089                    void *key, u32 sz_bytes,
0090                    u32 key_type, u32 *p_key_id);
0091 void mlx5_destroy_encryption_key(struct mlx5_core_dev *mdev, u32 key_id);
0092 
0093 static inline struct net *mlx5_core_net(struct mlx5_core_dev *dev)
0094 {
0095     return devlink_net(priv_to_devlink(dev));
0096 }
0097 
0098 static inline void mlx5_uplink_netdev_set(struct mlx5_core_dev *mdev, struct net_device *netdev)
0099 {
0100     mdev->mlx5e_res.uplink_netdev = netdev;
0101 }
0102 
0103 static inline struct net_device *mlx5_uplink_netdev_get(struct mlx5_core_dev *mdev)
0104 {
0105     return mdev->mlx5e_res.uplink_netdev;
0106 }
0107 #endif