/* * Copyright (c) 2012 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ /***********************************************************/ /*This file support the handling of the Alias GUID feature. */ /***********************************************************/ #include <rdma/ib_mad.h> #include <rdma/ib_smi.h> #include <rdma/ib_cache.h> #include <rdma/ib_sa.h> #include <rdma/ib_pack.h> #include <linux/mlx4/cmd.h> #include <linux/init.h> #include <linux/errno.h> #include <rdma/ib_user_verbs.h> #include <linux/delay.h> #include "mlx4_ib.h" /* The driver keeps the current state of all guids, as they are in the HW. Whenever we receive an smp mad GUIDInfo record, the data will be cached. */ struct mlx4_alias_guid_work_context { … }; struct mlx4_next_alias_guid_work { … }; static int get_low_record_time_index(struct mlx4_ib_dev *dev, u8 port, int *resched_delay_sec); void mlx4_ib_update_cache_on_guid_change(struct mlx4_ib_dev *dev, int block_num, u32 port_num, u8 *p_data) { … } static __be64 get_cached_alias_guid(struct mlx4_ib_dev *dev, int port, int index) { … } ib_sa_comp_mask mlx4_ib_get_aguid_comp_mask_from_ix(int index) { … } void mlx4_ib_slave_alias_guid_event(struct mlx4_ib_dev *dev, int slave, int port, int slave_init) { … } /* * Whenever new GUID is set/unset (guid table change) create event and * notify the relevant slave (master also should be notified). * If the GUID value is not as we have in the cache the slave will not be * updated; in this case it waits for the smp_snoop or the port management * event to call the function and to update the slave. * block_number - the index of the block (16 blocks available) * port_number - 1 or 2 */ void mlx4_ib_notify_slaves_on_guid_change(struct mlx4_ib_dev *dev, int block_num, u32 port_num, u8 *p_data) { … } static void aliasguid_query_handler(int status, struct ib_sa_guidinfo_rec *guid_rec, void *context) { … } static void invalidate_guid_record(struct mlx4_ib_dev *dev, u8 port, int index) { … } static int set_guid_rec(struct ib_device *ibdev, struct mlx4_next_alias_guid_work *rec) { … } static void mlx4_ib_guid_port_init(struct mlx4_ib_dev *dev, int port) { … } void mlx4_ib_invalidate_all_guid_record(struct mlx4_ib_dev *dev, int port) { … } static void set_required_record(struct mlx4_ib_dev *dev, u8 port, struct mlx4_next_alias_guid_work *next_rec, int record_index) { … } /* return index of record that should be updated based on lowest * rescheduled time */ static int get_low_record_time_index(struct mlx4_ib_dev *dev, u8 port, int *resched_delay_sec) { … } /* The function returns the next record that was * not configured (or failed to be configured) */ static int get_next_record_to_update(struct mlx4_ib_dev *dev, u8 port, struct mlx4_next_alias_guid_work *rec) { … } static void alias_guid_work(struct work_struct *work) { … } void mlx4_ib_init_alias_guid_work(struct mlx4_ib_dev *dev, int port) { … } void mlx4_ib_destroy_alias_guid_service(struct mlx4_ib_dev *dev) { … } int mlx4_ib_init_alias_guid_service(struct mlx4_ib_dev *dev) { … }