From: Roland Dreier <roland@topspin.com>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org, openib-general@openib.org
Subject: [PATCH][3/12] InfiniBand/mthca: implement modifying port attributes
Date: Sun, 23 Jan 2005 22:14:23 -0800 [thread overview]
Message-ID: <20051232214.v4gD7pRb7UQo64yW@topspin.com> (raw)
In-Reply-To: <20051232214.G5RSVEyRyy7IWtkk@topspin.com>
Implement the port_modify() device method for mthca using the SET_IB
firmware command. In particular this allows changing the port
capability mask.
Signed-off-by: Roland Dreier <roland@topspin.com>
--- linux-bk.orig/drivers/infiniband/hw/mthca/mthca_cmd.h 2005-01-23 20:38:50.944248064 -0800
+++ linux-bk/drivers/infiniband/hw/mthca/mthca_cmd.h 2005-01-23 20:39:02.039561320 -0800
@@ -215,6 +215,13 @@
u64 si_guid;
};
+struct mthca_set_ib_param {
+ int set_si_guid;
+ int reset_qkey_viol;
+ u64 si_guid;
+ u32 cap_mask;
+};
+
int mthca_cmd_use_events(struct mthca_dev *dev);
void mthca_cmd_use_polling(struct mthca_dev *dev);
void mthca_cmd_event(struct mthca_dev *dev, u16 token,
@@ -241,6 +248,8 @@
int port, u8 *status);
int mthca_CLOSE_IB(struct mthca_dev *dev, int port, u8 *status);
int mthca_CLOSE_HCA(struct mthca_dev *dev, int panic, u8 *status);
+int mthca_SET_IB(struct mthca_dev *dev, struct mthca_set_ib_param *param,
+ int port, u8 *status);
int mthca_MAP_ICM(struct mthca_dev *dev, struct mthca_icm *icm, u64 virt, u8 *status);
int mthca_MAP_ICM_page(struct mthca_dev *dev, u64 dma_addr, u64 virt, u8 *status);
int mthca_UNMAP_ICM(struct mthca_dev *dev, u64 virt, u32 page_count, u8 *status);
--- linux-bk.orig/drivers/infiniband/hw/mthca/mthca_provider.c 2005-01-23 20:38:25.991041528 -0800
+++ linux-bk/drivers/infiniband/hw/mthca/mthca_provider.c 2005-01-23 20:39:02.036561776 -0800
@@ -137,7 +137,35 @@
u8 port, int port_modify_mask,
struct ib_port_modify *props)
{
- return 0;
+ struct mthca_set_ib_param set_ib;
+ struct ib_port_attr attr;
+ int err;
+ u8 status;
+
+ if (down_interruptible(&to_mdev(ibdev)->cap_mask_mutex))
+ return -ERESTARTSYS;
+
+ err = mthca_query_port(ibdev, port, &attr);
+ if (err)
+ goto out;
+
+ set_ib.set_si_guid = 0;
+ set_ib.reset_qkey_viol = !!(port_modify_mask & IB_PORT_RESET_QKEY_CNTR);
+
+ set_ib.cap_mask = (attr.port_cap_flags | props->set_port_cap_mask) &
+ ~props->clr_port_cap_mask;
+
+ err = mthca_SET_IB(to_mdev(ibdev), &set_ib, port, &status);
+ if (err)
+ goto out;
+ if (status) {
+ err = -EINVAL;
+ goto out;
+ }
+
+out:
+ up(&to_mdev(ibdev)->cap_mask_mutex);
+ return err;
}
static int mthca_query_pkey(struct ib_device *ibdev,
@@ -619,6 +647,8 @@
}
}
+ init_MUTEX(&dev->cap_mask_mutex);
+
return 0;
}
--- linux-bk.orig/drivers/infiniband/hw/mthca/mthca_cmd.c 2005-01-23 20:38:50.949247304 -0800
+++ linux-bk/drivers/infiniband/hw/mthca/mthca_cmd.c 2005-01-23 20:39:02.038561472 -0800
@@ -1238,6 +1238,41 @@
return mthca_cmd(dev, 0, 0, panic, CMD_CLOSE_HCA, HZ, status);
}
+int mthca_SET_IB(struct mthca_dev *dev, struct mthca_set_ib_param *param,
+ int port, u8 *status)
+{
+ u32 *inbox;
+ dma_addr_t indma;
+ int err;
+ u32 flags = 0;
+
+#define SET_IB_IN_SIZE 0x40
+#define SET_IB_FLAGS_OFFSET 0x00
+#define SET_IB_FLAG_SIG (1 << 18)
+#define SET_IB_FLAG_RQK (1 << 0)
+#define SET_IB_CAP_MASK_OFFSET 0x04
+#define SET_IB_SI_GUID_OFFSET 0x08
+
+ inbox = pci_alloc_consistent(dev->pdev, SET_IB_IN_SIZE, &indma);
+ if (!inbox)
+ return -ENOMEM;
+
+ memset(inbox, 0, SET_IB_IN_SIZE);
+
+ flags |= param->set_si_guid ? SET_IB_FLAG_SIG : 0;
+ flags |= param->reset_qkey_viol ? SET_IB_FLAG_RQK : 0;
+ MTHCA_PUT(inbox, flags, SET_IB_FLAGS_OFFSET);
+
+ MTHCA_PUT(inbox, param->cap_mask, SET_IB_CAP_MASK_OFFSET);
+ MTHCA_PUT(inbox, param->si_guid, SET_IB_SI_GUID_OFFSET);
+
+ err = mthca_cmd(dev, indma, port, 0, CMD_SET_IB,
+ CMD_TIME_CLASS_B, status);
+
+ pci_free_consistent(dev->pdev, INIT_HCA_IN_SIZE, inbox, indma);
+ return err;
+}
+
int mthca_MAP_ICM(struct mthca_dev *dev, struct mthca_icm *icm, u64 virt, u8 *status)
{
return mthca_map_cmd(dev, CMD_MAP_ICM, icm, virt, status);
--- linux-bk.orig/drivers/infiniband/hw/mthca/mthca_dev.h 2005-01-23 20:38:50.950247152 -0800
+++ linux-bk/drivers/infiniband/hw/mthca/mthca_dev.h 2005-01-23 20:39:02.036561776 -0800
@@ -234,6 +234,7 @@
u64 ddr_end;
MTHCA_DECLARE_DOORBELL_LOCK(doorbell_lock)
+ struct semaphore cap_mask_mutex;
void __iomem *hcr;
void __iomem *clr_base;
next prev parent reply other threads:[~2005-01-24 6:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-24 6:14 [PATCH][0/12] InfiniBand: updates for 2.6.11-rc2 Roland Dreier
2005-01-24 6:14 ` [PATCH][1/12] InfiniBand/core: compat_ioctl conversion minor fixes Roland Dreier
2005-01-24 6:14 ` [PATCH][2/12] InfiniBand/mthca: more Arbel Mem-Free support Roland Dreier
2005-01-24 6:14 ` Roland Dreier [this message]
2005-01-24 6:14 ` [PATCH][4/12] InfiniBand/core: fix port capability enums bit order Roland Dreier
2005-01-24 6:14 ` [PATCH][5/12] InfiniBand/mthca: don't write ECR in MSI-X mode Roland Dreier
2005-01-24 6:14 ` [PATCH][6/12] InfiniBand/mthca: pass full process_mad info to firmware Roland Dreier
2005-01-24 6:14 ` [PATCH][7/12] InfiniBand/mthca: optimize event queue handling Roland Dreier
2005-01-24 6:14 ` [PATCH][8/12] InfiniBand/mthca: test IRQ routing during initialization Roland Dreier
2005-01-24 6:14 ` [PATCH][9/12] InfiniBand/ipoib: remove uses of yield() Roland Dreier
2005-01-24 6:14 ` [PATCH][10/12] InfiniBand/core: add IsSM userspace support Roland Dreier
2005-01-24 6:14 ` [PATCH][11/12] InfiniBand/mthca: clean up ioremap()/request_region() usage Roland Dreier
2005-01-24 6:14 ` [PATCH][12/12] InfiniBand/mthca: remove x86 SSE pessimization Roland Dreier
2005-01-24 18:44 ` [openib-general] [PATCH][13/12] InfiniBand/mthca: initialize mutex earlier Roland Dreier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20051232214.v4gD7pRb7UQo64yW@topspin.com \
--to=roland@topspin.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=openib-general@openib.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®