driver.h revision 273246
1301549Spfg/* 2301549Spfg * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. 3301549Spfg * 4301549Spfg * This software is available to you under a choice of one of two 5301549Spfg * licenses. You may choose to be licensed under the terms of the GNU 6301549Spfg * General Public License (GPL) Version 2, available from the file 7301549Spfg * COPYING in the main directory of this source tree, or the 8301549Spfg * OpenIB.org BSD license below: 9301549Spfg * 10301549Spfg * Redistribution and use in source and binary forms, with or 11301549Spfg * without modification, are permitted provided that the following 12301549Spfg * conditions are met: 13301549Spfg * 14301549Spfg * - Redistributions of source code must retain the above 15301549Spfg * copyright notice, this list of conditions and the following 16301549Spfg * disclaimer. 17301549Spfg * 18301549Spfg * - Redistributions in binary form must reproduce the above 19301549Spfg * copyright notice, this list of conditions and the following 20301549Spfg * disclaimer in the documentation and/or other materials 21301549Spfg * provided with the distribution. 22301549Spfg * 23301549Spfg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24301549Spfg * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25301549Spfg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26301549Spfg * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 27301549Spfg * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 28301549Spfg * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29301549Spfg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30301549Spfg * SOFTWARE. 31301549Spfg */ 32301549Spfg 33301549Spfg#ifndef MLX4_DRIVER_H 34301549Spfg#define MLX4_DRIVER_H 35301549Spfg 36301549Spfg#include <linux/mlx4/device.h> 37301549Spfg 38301549Spfgstruct mlx4_dev; 39301549Spfg 40301549Spfg#define MLX4_MAC_MASK 0xffffffffffffULL 41301549Spfg#define MLX4_BE_SHORT_MASK cpu_to_be16(0xffff) 42301549Spfg#define MLX4_BE_WORD_MASK cpu_to_be32(0xffffffff) 43301549Spfg 44301549Spfgenum mlx4_dev_event { 45301549Spfg MLX4_DEV_EVENT_CATASTROPHIC_ERROR, 46301549Spfg MLX4_DEV_EVENT_PORT_UP, 47301549Spfg MLX4_DEV_EVENT_PORT_DOWN, 48301549Spfg MLX4_DEV_EVENT_PORT_REINIT, 49301549Spfg MLX4_DEV_EVENT_PORT_MGMT_CHANGE, 50301549Spfg MLX4_DEV_EVENT_SLAVE_INIT, 51301549Spfg MLX4_DEV_EVENT_SLAVE_SHUTDOWN, 52301549Spfg}; 53301549Spfg 54301549Spfgstruct mlx4_interface { 55301549Spfg void * (*add) (struct mlx4_dev *dev); 56301549Spfg void (*remove)(struct mlx4_dev *dev, void *context); 57301549Spfg void (*event) (struct mlx4_dev *dev, void *context, 58301549Spfg enum mlx4_dev_event event, unsigned long param); 59301549Spfg void * (*get_dev)(struct mlx4_dev *dev, void *context, u8 port); 60301549Spfg struct list_head list; 61301549Spfg enum mlx4_protocol protocol; 62301549Spfg}; 63301549Spfg 64301549Spfgenum { 65301549Spfg MLX4_MAX_DEVICES = 32, 66301549Spfg MLX4_DEVS_TBL_SIZE = MLX4_MAX_DEVICES + 1, 67301549Spfg MLX4_DBDF2VAL_STR_SIZE = 512, 68301549Spfg MLX4_STR_NAME_SIZE = 64, 69301549Spfg MLX4_MAX_BDF_VALS = 2, 70301549Spfg MLX4_ENDOF_TBL = -1LL 71301549Spfg}; 72301549Spfg 73301549Spfgstruct mlx4_dbdf2val { 74301549Spfg u64 dbdf; 75301549Spfg int val[MLX4_MAX_BDF_VALS]; 76301549Spfg}; 77301549Spfg 78301549Spfgstruct mlx4_range { 79301549Spfg int min; 80301549Spfg int max; 81301549Spfg}; 82301549Spfg 83301549Spfg/* 84301549Spfg * mlx4_dbdf2val_lst struct holds all the data needed to convert 85301549Spfg * dbdf-to-value-list string into dbdf-to-value table. 86301549Spfg * dbdf-to-value-list string is a comma separated list of dbdf-to-value strings. 87301549Spfg * the format of dbdf-to-value string is: "[mmmm:]bb:dd.f-v1[;v2]" 88301549Spfg * mmmm - Domain number (optional) 89301549Spfg * bb - Bus number 90301549Spfg * dd - device number 91301549Spfg * f - Function number 92301549Spfg * v1 - First value related to the domain-bus-device-function. 93301549Spfg * v2 - Second value related to the domain-bus-device-function (optional). 94301549Spfg * bb, dd - Two hexadecimal digits without preceding 0x. 95301549Spfg * mmmm - Four hexadecimal digits without preceding 0x. 96301549Spfg * f - One hexadecimal without preceding 0x. 97301549Spfg * v1,v2 - Number with normal convention (e.g 100, 0xd3). 98301549Spfg * dbdf-to-value-list string format: 99301549Spfg * "[mmmm:]bb:dd.f-v1[;v2],[mmmm:]bb:dd.f-v1[;v2],..." 100301549Spfg * 101301549Spfg */ 102301549Spfgstruct mlx4_dbdf2val_lst { 103301549Spfg char name[MLX4_STR_NAME_SIZE]; /* String name */ 104301549Spfg char str[MLX4_DBDF2VAL_STR_SIZE]; /* dbdf2val list str */ 105301549Spfg struct mlx4_dbdf2val tbl[MLX4_DEVS_TBL_SIZE];/* dbdf to value table */ 106301549Spfg int num_vals; /* # of vals per dbdf */ 107301549Spfg int def_val[MLX4_MAX_BDF_VALS]; /* Default values */ 108301549Spfg struct mlx4_range range; /* Valid values range */ 109301549Spfg}; 110301549Spfg 111301549Spfgint mlx4_fill_dbdf2val_tbl(struct mlx4_dbdf2val_lst *dbdf2val_lst); 112301549Spfgint mlx4_get_val(struct mlx4_dbdf2val *tbl, struct pci_dev *pdev, int idx, 113301549Spfg int *val); 114301549Spfg 115301549Spfgint mlx4_register_interface(struct mlx4_interface *intf); 116301549Spfgvoid mlx4_unregister_interface(struct mlx4_interface *intf); 117301549Spfg 118301549Spfgvoid *mlx4_get_protocol_dev(struct mlx4_dev *dev, enum mlx4_protocol proto, 119301549Spfg int port); 120301549Spfg 121301549Spfg#ifndef ETH_ALEN 122301549Spfg#define ETH_ALEN 6 123301549Spfg#endif 124301549Spfgstatic inline u64 mlx4_mac_to_u64(const u8 *addr) 125301549Spfg{ 126301549Spfg u64 mac = 0; 127301549Spfg int i; 128301549Spfg 129301549Spfg for (i = 0; i < ETH_ALEN; i++) { 130301549Spfg mac <<= 8; 131301549Spfg mac |= addr[i]; 132301549Spfg } 133301549Spfg return mac; 134301549Spfg} 135301549Spfg 136301549Spfg#endif /* MLX4_DRIVER_H */ 137301549Spfg