1250757Sjkim/* 2250757Sjkim * Copyright (c) 2007 Cisco, Inc. All rights reserved. 3250757Sjkim * 4250757Sjkim * This software is available to you under a choice of one of two 5250757Sjkim * licenses. You may choose to be licensed under the terms of the GNU 6250757Sjkim * General Public License (GPL) Version 2, available from the file 7250757Sjkim * COPYING in the main directory of this source tree, or the 8306536Sjkim * OpenIB.org BSD license below: 9250757Sjkim * 10250757Sjkim * Redistribution and use in source and binary forms, with or 11250757Sjkim * without modification, are permitted provided that the following 12250757Sjkim * conditions are met: 13250757Sjkim * 14250757Sjkim * - Redistributions of source code must retain the above 15250757Sjkim * copyright notice, this list of conditions and the following 16250757Sjkim * disclaimer. 17250757Sjkim * 18250757Sjkim * - Redistributions in binary form must reproduce the above 19250757Sjkim * copyright notice, this list of conditions and the following 20250757Sjkim * disclaimer in the documentation and/or other materials 21250757Sjkim * provided with the distribution. 22250757Sjkim * 23250757Sjkim * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24250757Sjkim * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25250757Sjkim * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26250757Sjkim * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 27250757Sjkim * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 28250757Sjkim * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29250757Sjkim * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30250757Sjkim * SOFTWARE. 31250757Sjkim */ 32250757Sjkim 33250757Sjkim#ifndef DOORBELL_H 34250757Sjkim#define DOORBELL_H 35250757Sjkim 36250757Sjkim#ifdef __LP64__ 37250757Sjkim#if __BYTE_ORDER == __LITTLE_ENDIAN 38250757Sjkim# define MLX4_PAIR_TO_64(val) ((uint64_t) val[1] << 32 | val[0]) 39250757Sjkim#elif __BYTE_ORDER == __BIG_ENDIAN 40250757Sjkim# define MLX4_PAIR_TO_64(val) ((uint64_t) val[0] << 32 | val[1]) 41250757Sjkim#else 42250757Sjkim# error __BYTE_ORDER not defined 43250757Sjkim#endif 44250838Sjkim 45250838Sjkimstatic inline void mlx4_write64(uint32_t val[2], struct mlx4_context *ctx, int offset) 46250838Sjkim{ 47250757Sjkim *(volatile uint64_t *) (ctx->uar + offset) = MLX4_PAIR_TO_64(val); 48250757Sjkim} 49250757Sjkim 50250757Sjkim#else 51250757Sjkim 52250757Sjkimstatic inline void mlx4_write64(uint32_t val[2], struct mlx4_context *ctx, int offset) 53250757Sjkim{ 54250757Sjkim pthread_spin_lock(&ctx->uar_lock); 55250757Sjkim *(volatile uint32_t *) (ctx->uar + offset) = val[0]; 56250757Sjkim *(volatile uint32_t *) (ctx->uar + offset + 4) = val[1]; 57250757Sjkim pthread_spin_unlock(&ctx->uar_lock); 58250757Sjkim} 59250757Sjkim 60250757Sjkim#endif 61250757Sjkim 62250757Sjkim#endif /* DOORBELL_H */ 63250757Sjkim