197549c34SHans Petter Selasky /* 297549c34SHans Petter Selasky * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. 397549c34SHans Petter Selasky * 497549c34SHans Petter Selasky * This software is available to you under a choice of one of two 597549c34SHans Petter Selasky * licenses. You may choose to be licensed under the terms of the GNU 697549c34SHans Petter Selasky * General Public License (GPL) Version 2, available from the file 797549c34SHans Petter Selasky * COPYING in the main directory of this source tree, or the 897549c34SHans Petter Selasky * OpenIB.org BSD license below: 997549c34SHans Petter Selasky * 1097549c34SHans Petter Selasky * Redistribution and use in source and binary forms, with or 1197549c34SHans Petter Selasky * without modification, are permitted provided that the following 1297549c34SHans Petter Selasky * conditions are met: 1397549c34SHans Petter Selasky * 1497549c34SHans Petter Selasky * - Redistributions of source code must retain the above 1597549c34SHans Petter Selasky * copyright notice, this list of conditions and the following 1697549c34SHans Petter Selasky * disclaimer. 1797549c34SHans Petter Selasky * 1897549c34SHans Petter Selasky * - Redistributions in binary form must reproduce the above 1997549c34SHans Petter Selasky * copyright notice, this list of conditions and the following 2097549c34SHans Petter Selasky * disclaimer in the documentation and/or other materials 2197549c34SHans Petter Selasky * provided with the distribution. 2297549c34SHans Petter Selasky * 2397549c34SHans Petter Selasky * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 2497549c34SHans Petter Selasky * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2597549c34SHans Petter Selasky * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2697549c34SHans Petter Selasky * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 2797549c34SHans Petter Selasky * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 2897549c34SHans Petter Selasky * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 2997549c34SHans Petter Selasky * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 3097549c34SHans Petter Selasky * SOFTWARE. 3197549c34SHans Petter Selasky */ 3297549c34SHans Petter Selasky 3397549c34SHans Petter Selasky #ifndef MLX4_DRIVER_H 3497549c34SHans Petter Selasky #define MLX4_DRIVER_H 3597549c34SHans Petter Selasky 3697549c34SHans Petter Selasky #include <dev/mlx4/device.h> 3797549c34SHans Petter Selasky 3897549c34SHans Petter Selasky struct mlx4_dev; 3997549c34SHans Petter Selasky 4097549c34SHans Petter Selasky #define MLX4_MAC_MASK 0xffffffffffffULL 4197549c34SHans Petter Selasky 4297549c34SHans Petter Selasky enum mlx4_dev_event { 4397549c34SHans Petter Selasky MLX4_DEV_EVENT_CATASTROPHIC_ERROR, 4497549c34SHans Petter Selasky MLX4_DEV_EVENT_PORT_UP, 4597549c34SHans Petter Selasky MLX4_DEV_EVENT_PORT_DOWN, 4697549c34SHans Petter Selasky MLX4_DEV_EVENT_PORT_REINIT, 4797549c34SHans Petter Selasky MLX4_DEV_EVENT_PORT_MGMT_CHANGE, 4897549c34SHans Petter Selasky MLX4_DEV_EVENT_SLAVE_INIT, 4997549c34SHans Petter Selasky MLX4_DEV_EVENT_SLAVE_SHUTDOWN, 5097549c34SHans Petter Selasky }; 5197549c34SHans Petter Selasky 52c3191c2eSHans Petter Selasky enum { 53c3191c2eSHans Petter Selasky MLX4_INTFF_BONDING = 1 << 0 54c3191c2eSHans Petter Selasky }; 55c3191c2eSHans Petter Selasky 5697549c34SHans Petter Selasky struct mlx4_interface { 5797549c34SHans Petter Selasky void * (*add) (struct mlx4_dev *dev); 5897549c34SHans Petter Selasky void (*remove)(struct mlx4_dev *dev, void *context); 5997549c34SHans Petter Selasky void (*event) (struct mlx4_dev *dev, void *context, 6097549c34SHans Petter Selasky enum mlx4_dev_event event, unsigned long param); 6197549c34SHans Petter Selasky void * (*get_dev)(struct mlx4_dev *dev, void *context, u8 port); 62c3191c2eSHans Petter Selasky void (*activate)(struct mlx4_dev *dev, void *context); 6397549c34SHans Petter Selasky struct list_head list; 6497549c34SHans Petter Selasky enum mlx4_protocol protocol; 65c3191c2eSHans Petter Selasky int flags; 6697549c34SHans Petter Selasky }; 6797549c34SHans Petter Selasky 6897549c34SHans Petter Selasky int mlx4_register_interface(struct mlx4_interface *intf); 6997549c34SHans Petter Selasky void mlx4_unregister_interface(struct mlx4_interface *intf); 7097549c34SHans Petter Selasky 71c3191c2eSHans Petter Selasky int mlx4_bond(struct mlx4_dev *dev); 72c3191c2eSHans Petter Selasky int mlx4_unbond(struct mlx4_dev *dev); 73c3191c2eSHans Petter Selasky static inline int mlx4_is_bonded(struct mlx4_dev *dev) 74c3191c2eSHans Petter Selasky { 75c3191c2eSHans Petter Selasky return !!(dev->flags & MLX4_FLAG_BONDED); 76c3191c2eSHans Petter Selasky } 7797549c34SHans Petter Selasky 78c3191c2eSHans Petter Selasky static inline int mlx4_is_mf_bonded(struct mlx4_dev *dev) 79c3191c2eSHans Petter Selasky { 80c3191c2eSHans Petter Selasky return (mlx4_is_bonded(dev) && mlx4_is_mfunc(dev)); 81c3191c2eSHans Petter Selasky } 82c3191c2eSHans Petter Selasky 83c3191c2eSHans Petter Selasky struct mlx4_port_map { 84c3191c2eSHans Petter Selasky u8 port1; 85c3191c2eSHans Petter Selasky u8 port2; 86c3191c2eSHans Petter Selasky }; 87c3191c2eSHans Petter Selasky 88c3191c2eSHans Petter Selasky int mlx4_port_map_set(struct mlx4_dev *dev, struct mlx4_port_map *v2p); 89c3191c2eSHans Petter Selasky 90c3191c2eSHans Petter Selasky void *mlx4_get_protocol_dev(struct mlx4_dev *dev, enum mlx4_protocol proto, int port); 91c3191c2eSHans Petter Selasky 9297549c34SHans Petter Selasky static inline u64 mlx4_mac_to_u64(const u8 *addr) 9397549c34SHans Petter Selasky { 9497549c34SHans Petter Selasky u64 mac = 0; 9597549c34SHans Petter Selasky int i; 9697549c34SHans Petter Selasky 9797549c34SHans Petter Selasky for (i = 0; i < ETH_ALEN; i++) { 9897549c34SHans Petter Selasky mac <<= 8; 9997549c34SHans Petter Selasky mac |= addr[i]; 10097549c34SHans Petter Selasky } 10197549c34SHans Petter Selasky return mac; 10297549c34SHans Petter Selasky } 10397549c34SHans Petter Selasky 104*63d7a8d9SSlava Shwartsman void mlx4_disable_interrupts(struct mlx4_dev *); 105*63d7a8d9SSlava Shwartsman void mlx4_poll_interrupts(struct mlx4_dev *); 106*63d7a8d9SSlava Shwartsman 10797549c34SHans Petter Selasky #endif /* MLX4_DRIVER_H */ 108