/* * Copyright (c) 2004, 2005, 2006 Voltaire, Inc. All rights reserved. * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved. * Copyright (c) 2013-2014 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. */ #include <linux/kernel.h> #include <linux/slab.h> #include <linux/delay.h> #include "iscsi_iser.h" static void iser_qp_event_callback(struct ib_event *cause, void *context) { … } static void iser_event_handler(struct ib_event_handler *handler, struct ib_event *event) { … } /* * iser_create_device_ib_res - creates Protection Domain (PD), Completion * Queue (CQ), DMA Memory Region (DMA MR) with the device associated with * the adaptor. * * Return: 0 on success, -1 on failure */ static int iser_create_device_ib_res(struct iser_device *device) { … } /* * iser_free_device_ib_res - destroy/dealloc/dereg the DMA MR, * CQ and PD created with the device associated with the adaptor. */ static void iser_free_device_ib_res(struct iser_device *device) { … } static struct iser_fr_desc * iser_create_fastreg_desc(struct iser_device *device, struct ib_pd *pd, bool pi_enable, unsigned int size) { … } static void iser_destroy_fastreg_desc(struct iser_fr_desc *desc) { … } /** * iser_alloc_fastreg_pool - Creates pool of fast_reg descriptors * for fast registration work requests. * @ib_conn: connection RDMA resources * @cmds_max: max number of SCSI commands for this connection * @size: max number of pages per map request * * Return: 0 on success, or errno code on failure */ int iser_alloc_fastreg_pool(struct ib_conn *ib_conn, unsigned cmds_max, unsigned int size) { … } /** * iser_free_fastreg_pool - releases the pool of fast_reg descriptors * @ib_conn: connection RDMA resources */ void iser_free_fastreg_pool(struct ib_conn *ib_conn) { … } /* * iser_create_ib_conn_res - Queue-Pair (QP) * * Return: 0 on success, -1 on failure */ static int iser_create_ib_conn_res(struct ib_conn *ib_conn) { … } /* * based on the resolved device node GUID see if there already allocated * device for this device. If there's no such, create one. */ static struct iser_device *iser_device_find_by_ib_device(struct rdma_cm_id *cma_id) { … } /* if there's no demand for this device, release it */ static void iser_device_try_release(struct iser_device *device) { … } void iser_release_work(struct work_struct *work) { … } /** * iser_free_ib_conn_res - release IB related resources * @iser_conn: iser connection struct * @destroy: indicator if we need to try to release the * iser device and memory regoins pool (only iscsi * shutdown and DEVICE_REMOVAL will use this). * * This routine is called with the iser state mutex held * so the cm_id removal is out of here. It is Safe to * be invoked multiple times. */ static void iser_free_ib_conn_res(struct iser_conn *iser_conn, bool destroy) { … } /** * iser_conn_release - Frees all conn objects and deallocs conn descriptor * @iser_conn: iSER connection context */ void iser_conn_release(struct iser_conn *iser_conn) { … } /** * iser_conn_terminate - triggers start of the disconnect procedures and * waits for them to be done * @iser_conn: iSER connection context * * Called with state mutex held */ int iser_conn_terminate(struct iser_conn *iser_conn) { … } /* * Called with state mutex held */ static void iser_connect_error(struct rdma_cm_id *cma_id) { … } static void iser_calc_scsi_params(struct iser_conn *iser_conn, unsigned int max_sectors) { … } /* * Called with state mutex held */ static void iser_addr_handler(struct rdma_cm_id *cma_id) { … } /* * Called with state mutex held */ static void iser_route_handler(struct rdma_cm_id *cma_id) { … } /* * Called with state mutex held */ static void iser_connected_handler(struct rdma_cm_id *cma_id, const void *private_data) { … } /* * Called with state mutex held */ static void iser_cleanup_handler(struct rdma_cm_id *cma_id, bool destroy) { … } static int iser_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event) { … } void iser_conn_init(struct iser_conn *iser_conn) { … } /* * starts the process of connecting to the target * sleeps until the connection is established or rejected */ int iser_connect(struct iser_conn *iser_conn, struct sockaddr *src_addr, struct sockaddr *dst_addr, int non_blocking) { … } int iser_post_recvl(struct iser_conn *iser_conn) { … } int iser_post_recvm(struct iser_conn *iser_conn, struct iser_rx_desc *rx_desc) { … } /** * iser_post_send - Initiate a Send DTO operation * @ib_conn: connection RDMA resources * @tx_desc: iSER TX descriptor * * Return: 0 on success, -1 on failure */ int iser_post_send(struct ib_conn *ib_conn, struct iser_tx_desc *tx_desc) { … } u8 iser_check_task_pi_status(struct iscsi_iser_task *iser_task, enum iser_data_dir cmd_dir, sector_t *sector) { … } void iser_err_comp(struct ib_wc *wc, const char *type) { … }