![]() |
|
|||
0001 /* 0002 * Copyright (c) 2004 Topspin Communications. All rights reserved. 0003 * Copyright (c) 2005 Cisco Systems. All rights reserved. 0004 * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 0005 * 0006 * This software is available to you under a choice of one of two 0007 * licenses. You may choose to be licensed under the terms of the GNU 0008 * General Public License (GPL) Version 2, available from the file 0009 * COPYING in the main directory of this source tree, or the 0010 * OpenIB.org BSD license below: 0011 * 0012 * Redistribution and use in source and binary forms, with or 0013 * without modification, are permitted provided that the following 0014 * conditions are met: 0015 * 0016 * - Redistributions of source code must retain the above 0017 * copyright notice, this list of conditions and the following 0018 * disclaimer. 0019 * 0020 * - Redistributions in binary form must reproduce the above 0021 * copyright notice, this list of conditions and the following 0022 * disclaimer in the documentation and/or other materials 0023 * provided with the distribution. 0024 * 0025 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 0026 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 0027 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 0028 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 0029 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 0030 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 0031 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 0032 * SOFTWARE. 0033 */ 0034 0035 #include <linux/errno.h> 0036 0037 #include "mthca_dev.h" 0038 0039 int mthca_pd_alloc(struct mthca_dev *dev, int privileged, struct mthca_pd *pd) 0040 { 0041 int err = 0; 0042 0043 pd->privileged = privileged; 0044 0045 atomic_set(&pd->sqp_count, 0); 0046 pd->pd_num = mthca_alloc(&dev->pd_table.alloc); 0047 if (pd->pd_num == -1) 0048 return -ENOMEM; 0049 0050 if (privileged) { 0051 err = mthca_mr_alloc_notrans(dev, pd->pd_num, 0052 MTHCA_MPT_FLAG_LOCAL_READ | 0053 MTHCA_MPT_FLAG_LOCAL_WRITE, 0054 &pd->ntmr); 0055 if (err) 0056 mthca_free(&dev->pd_table.alloc, pd->pd_num); 0057 } 0058 0059 return err; 0060 } 0061 0062 void mthca_pd_free(struct mthca_dev *dev, struct mthca_pd *pd) 0063 { 0064 if (pd->privileged) 0065 mthca_free_mr(dev, &pd->ntmr); 0066 mthca_free(&dev->pd_table.alloc, pd->pd_num); 0067 } 0068 0069 int mthca_init_pd_table(struct mthca_dev *dev) 0070 { 0071 return mthca_alloc_init(&dev->pd_table.alloc, 0072 dev->limits.num_pds, 0073 (1 << 24) - 1, 0074 dev->limits.reserved_pds); 0075 } 0076 0077 void mthca_cleanup_pd_table(struct mthca_dev *dev) 0078 { 0079 /* XXX check if any PDs are still allocated? */ 0080 mthca_alloc_cleanup(&dev->pd_table.alloc); 0081 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |