From b39993936d3b192ea088995f7ba882a49e4bf09c Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Wed, 16 Apr 2008 21:01:03 -0700 Subject: IB/mthca: Formatting cleanups Fix a few whitespace and other coding style problems. Signed-off-by: Roland Dreier --- drivers/infiniband/hw/mthca/mthca_cmd.c | 2 +- drivers/infiniband/hw/mthca/mthca_dev.h | 10 +++++----- drivers/infiniband/hw/mthca/mthca_eq.c | 4 ++-- drivers/infiniband/hw/mthca/mthca_mad.c | 2 +- drivers/infiniband/hw/mthca/mthca_memfree.c | 2 +- drivers/infiniband/hw/mthca/mthca_provider.c | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) (limited to 'drivers/infiniband/hw/mthca') diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c index 09a30dd12b1..667c35ddb7c 100644 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c @@ -219,7 +219,7 @@ static void mthca_cmd_post_dbell(struct mthca_dev *dev, __raw_writel((__force u32) cpu_to_be32((1 << HCR_GO_BIT) | (1 << HCA_E_BIT) | (op_modifier << HCR_OPMOD_SHIFT) | - op), ptr + offs[6]); + op), ptr + offs[6]); wmb(); __raw_writel((__force u32) 0, ptr + offs[7]); wmb(); diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h b/drivers/infiniband/hw/mthca/mthca_dev.h index 7bbdd1f4e6c..f82ed832ad9 100644 --- a/drivers/infiniband/hw/mthca/mthca_dev.h +++ b/drivers/infiniband/hw/mthca/mthca_dev.h @@ -390,11 +390,11 @@ extern void __buggy_use_of_MTHCA_PUT(void); do { \ void *__p = (char *) (source) + (offset); \ switch (sizeof (dest)) { \ - case 1: (dest) = *(u8 *) __p; break; \ - case 2: (dest) = be16_to_cpup(__p); break; \ - case 4: (dest) = be32_to_cpup(__p); break; \ - case 8: (dest) = be64_to_cpup(__p); break; \ - default: __buggy_use_of_MTHCA_GET(); \ + case 1: (dest) = *(u8 *) __p; break; \ + case 2: (dest) = be16_to_cpup(__p); break; \ + case 4: (dest) = be32_to_cpup(__p); break; \ + case 8: (dest) = be64_to_cpup(__p); break; \ + default: __buggy_use_of_MTHCA_GET(); \ } \ } while (0) diff --git a/drivers/infiniband/hw/mthca/mthca_eq.c b/drivers/infiniband/hw/mthca/mthca_eq.c index b60eb5df96e..8bde7f98e58 100644 --- a/drivers/infiniband/hw/mthca/mthca_eq.c +++ b/drivers/infiniband/hw/mthca/mthca_eq.c @@ -232,9 +232,9 @@ static inline struct mthca_eqe *get_eqe(struct mthca_eq *eq, u32 entry) return eq->page_list[off / PAGE_SIZE].buf + off % PAGE_SIZE; } -static inline struct mthca_eqe* next_eqe_sw(struct mthca_eq *eq) +static inline struct mthca_eqe *next_eqe_sw(struct mthca_eq *eq) { - struct mthca_eqe* eqe; + struct mthca_eqe *eqe; eqe = get_eqe(eq, eq->cons_index); return (MTHCA_EQ_ENTRY_OWNER_HW & eqe->owner) ? NULL : eqe; } diff --git a/drivers/infiniband/hw/mthca/mthca_mad.c b/drivers/infiniband/hw/mthca/mthca_mad.c index acfa41d968e..8b7e83e6e88 100644 --- a/drivers/infiniband/hw/mthca/mthca_mad.c +++ b/drivers/infiniband/hw/mthca/mthca_mad.c @@ -125,7 +125,7 @@ static void smp_snoop(struct ib_device *ibdev, event.device = ibdev; event.element.port_num = port_num; - if(pinfo->clientrereg_resv_subnetto & 0x80) + if (pinfo->clientrereg_resv_subnetto & 0x80) event.event = IB_EVENT_CLIENT_REREGISTER; else event.event = IB_EVENT_LID_CHANGE; diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c index 252db0822f6..d7d502dd741 100644 --- a/drivers/infiniband/hw/mthca/mthca_memfree.c +++ b/drivers/infiniband/hw/mthca/mthca_memfree.c @@ -412,7 +412,7 @@ err: if (table->icm[i]) { mthca_UNMAP_ICM(dev, virt + i * MTHCA_TABLE_CHUNK_SIZE, MTHCA_TABLE_CHUNK_SIZE / MTHCA_ICM_PAGE_SIZE, - &status); + &status); mthca_free_icm(dev, table->icm[i], table->coherent); } diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c index 9e491df6419..ee9bc145622 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/drivers/infiniband/hw/mthca/mthca_provider.c @@ -60,7 +60,7 @@ static int mthca_query_device(struct ib_device *ibdev, struct ib_smp *in_mad = NULL; struct ib_smp *out_mad = NULL; int err = -ENOMEM; - struct mthca_dev* mdev = to_mdev(ibdev); + struct mthca_dev *mdev = to_mdev(ibdev); u8 status; -- cgit v1.2.3-70-g09d2 From 680b575f6d1ae8aa39c4d7ee7e40b749d277fa9f Mon Sep 17 00:00:00 2001 From: Eli Cohen Date: Wed, 16 Apr 2008 21:01:11 -0700 Subject: IB/mthca: Add IPoIB checksum offload support Arbel and Sinai devices support checksum generation and verification of TCP and UDP packets for UD IPoIB messages. This patch checks if the HCA supports this and sets the IB_DEVICE_UD_IP_CSUM capability flag if it does. It implements support for handling the IB_SEND_IP_CSUM send flag and setting the csum_ok field in receive work completions. Signed-off-by: Eli Cohen Signed-off-by: Roland Dreier --- drivers/infiniband/hw/mthca/mthca_cmd.c | 4 ++++ drivers/infiniband/hw/mthca/mthca_cmd.h | 1 + drivers/infiniband/hw/mthca/mthca_cq.c | 14 +++++++++----- drivers/infiniband/hw/mthca/mthca_main.c | 4 ++++ drivers/infiniband/hw/mthca/mthca_qp.c | 2 ++ drivers/infiniband/hw/mthca/mthca_wqe.h | 18 ++++++++++-------- 6 files changed, 30 insertions(+), 13 deletions(-) (limited to 'drivers/infiniband/hw/mthca') diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c index 667c35ddb7c..54d230ee7d6 100644 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c @@ -1339,6 +1339,10 @@ int mthca_INIT_HCA(struct mthca_dev *dev, /* Check port for UD address vector: */ *(inbox + INIT_HCA_FLAGS2_OFFSET / 4) |= cpu_to_be32(1); + /* Enable IPoIB checksumming if we can: */ + if (dev->device_cap_flags & IB_DEVICE_UD_IP_CSUM) + *(inbox + INIT_HCA_FLAGS2_OFFSET / 4) |= cpu_to_be32(7 << 3); + /* We leave wqe_quota, responder_exu, etc as 0 (default) */ /* QPC/EEC/CQC/EQC/RDB attributes */ diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.h b/drivers/infiniband/hw/mthca/mthca_cmd.h index 2f976f2051d..8928ca4a932 100644 --- a/drivers/infiniband/hw/mthca/mthca_cmd.h +++ b/drivers/infiniband/hw/mthca/mthca_cmd.h @@ -103,6 +103,7 @@ enum { DEV_LIM_FLAG_RAW_IPV6 = 1 << 4, DEV_LIM_FLAG_RAW_ETHER = 1 << 5, DEV_LIM_FLAG_SRQ = 1 << 6, + DEV_LIM_FLAG_IPOIB_CSUM = 1 << 7, DEV_LIM_FLAG_BAD_PKEY_CNTR = 1 << 8, DEV_LIM_FLAG_BAD_QKEY_CNTR = 1 << 9, DEV_LIM_FLAG_MW = 1 << 16, diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c index 1e1e336d3ef..20401d2ba6b 100644 --- a/drivers/infiniband/hw/mthca/mthca_cq.c +++ b/drivers/infiniband/hw/mthca/mthca_cq.c @@ -119,7 +119,8 @@ struct mthca_cqe { __be32 my_qpn; __be32 my_ee; __be32 rqpn; - __be16 sl_g_mlpath; + u8 sl_ipok; + u8 g_mlpath; __be16 rlid; __be32 imm_etype_pkey_eec; __be32 byte_cnt; @@ -493,6 +494,7 @@ static inline int mthca_poll_one(struct mthca_dev *dev, int is_send; int free_cqe = 1; int err = 0; + u16 checksum; cqe = next_cqe_sw(cq); if (!cqe) @@ -635,12 +637,14 @@ static inline int mthca_poll_one(struct mthca_dev *dev, break; } entry->slid = be16_to_cpu(cqe->rlid); - entry->sl = be16_to_cpu(cqe->sl_g_mlpath) >> 12; + entry->sl = cqe->sl_ipok >> 4; entry->src_qp = be32_to_cpu(cqe->rqpn) & 0xffffff; - entry->dlid_path_bits = be16_to_cpu(cqe->sl_g_mlpath) & 0x7f; + entry->dlid_path_bits = cqe->g_mlpath & 0x7f; entry->pkey_index = be32_to_cpu(cqe->imm_etype_pkey_eec) >> 16; - entry->wc_flags |= be16_to_cpu(cqe->sl_g_mlpath) & 0x80 ? - IB_WC_GRH : 0; + entry->wc_flags |= cqe->g_mlpath & 0x80 ? IB_WC_GRH : 0; + checksum = (be32_to_cpu(cqe->rqpn) >> 24) | + ((be32_to_cpu(cqe->my_ee) >> 16) & 0xff00); + entry->csum_ok = (cqe->sl_ipok & 1 && checksum == 0xffff); } entry->status = IB_WC_SUCCESS; diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c index cd3d8adbef9..3889ae859f5 100644 --- a/drivers/infiniband/hw/mthca/mthca_main.c +++ b/drivers/infiniband/hw/mthca/mthca_main.c @@ -267,6 +267,10 @@ static int mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim *dev_lim) if (dev_lim->flags & DEV_LIM_FLAG_SRQ) mdev->mthca_flags |= MTHCA_FLAG_SRQ; + if (mthca_is_memfree(mdev)) + if (dev_lim->flags & DEV_LIM_FLAG_IPOIB_CSUM) + mdev->device_cap_flags |= IB_DEVICE_UD_IP_CSUM; + return 0; } diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index db5595bbf7f..8433897624b 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c @@ -2015,6 +2015,8 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, cpu_to_be32(MTHCA_NEXT_CQ_UPDATE) : 0) | ((wr->send_flags & IB_SEND_SOLICITED) ? cpu_to_be32(MTHCA_NEXT_SOLICIT) : 0) | + ((wr->send_flags & IB_SEND_IP_CSUM) ? + cpu_to_be32(MTHCA_NEXT_IP_CSUM | MTHCA_NEXT_TCP_UDP_CSUM) : 0) | cpu_to_be32(1); if (wr->opcode == IB_WR_SEND_WITH_IMM || wr->opcode == IB_WR_RDMA_WRITE_WITH_IMM) diff --git a/drivers/infiniband/hw/mthca/mthca_wqe.h b/drivers/infiniband/hw/mthca/mthca_wqe.h index f6a66fe78e4..b3551a8dea1 100644 --- a/drivers/infiniband/hw/mthca/mthca_wqe.h +++ b/drivers/infiniband/hw/mthca/mthca_wqe.h @@ -38,14 +38,16 @@ #include enum { - MTHCA_NEXT_DBD = 1 << 7, - MTHCA_NEXT_FENCE = 1 << 6, - MTHCA_NEXT_CQ_UPDATE = 1 << 3, - MTHCA_NEXT_EVENT_GEN = 1 << 2, - MTHCA_NEXT_SOLICIT = 1 << 1, - - MTHCA_MLX_VL15 = 1 << 17, - MTHCA_MLX_SLR = 1 << 16 + MTHCA_NEXT_DBD = 1 << 7, + MTHCA_NEXT_FENCE = 1 << 6, + MTHCA_NEXT_CQ_UPDATE = 1 << 3, + MTHCA_NEXT_EVENT_GEN = 1 << 2, + MTHCA_NEXT_SOLICIT = 1 << 1, + MTHCA_NEXT_IP_CSUM = 1 << 4, + MTHCA_NEXT_TCP_UDP_CSUM = 1 << 5, + + MTHCA_MLX_VL15 = 1 << 17, + MTHCA_MLX_SLR = 1 << 16 }; enum { -- cgit v1.2.3-70-g09d2 From 19773539d6369c54fbb0c870de0c75417b0020d1 Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Wed, 16 Apr 2008 21:01:13 -0700 Subject: IB/mthca: Avoid integer overflow when dealing with profile size mthca_make_profile() returns the size in bytes of the HCA context layout it creates, or a negative value if an error occurs. However, the return value is declared as u64 and the memfree initialization path casts this value to int to test if it is negative. This makes it think incorrectly than an error has occurred if the context size happens to be bigger than 2GB, since this turns into a negative int. Fix this by having mthca_make_profile() return an s64 and testing for an error by checking whether this 64-bit value itself is negative. Signed-off-by: Roland Dreier --- drivers/infiniband/hw/mthca/mthca_main.c | 11 +++++++---- drivers/infiniband/hw/mthca/mthca_profile.c | 4 ++-- drivers/infiniband/hw/mthca/mthca_profile.h | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) (limited to 'drivers/infiniband/hw/mthca') diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c index 3889ae859f5..9ebadd6e0cf 100644 --- a/drivers/infiniband/hw/mthca/mthca_main.c +++ b/drivers/infiniband/hw/mthca/mthca_main.c @@ -276,6 +276,7 @@ static int mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim *dev_lim) static int mthca_init_tavor(struct mthca_dev *mdev) { + s64 size; u8 status; int err; struct mthca_dev_lim dev_lim; @@ -328,9 +329,11 @@ static int mthca_init_tavor(struct mthca_dev *mdev) if (mdev->mthca_flags & MTHCA_FLAG_SRQ) profile.num_srq = dev_lim.max_srqs; - err = mthca_make_profile(mdev, &profile, &dev_lim, &init_hca); - if (err < 0) + size = mthca_make_profile(mdev, &profile, &dev_lim, &init_hca); + if (size < 0) { + err = size; goto err_disable; + } err = mthca_INIT_HCA(mdev, &init_hca, &status); if (err) { @@ -609,7 +612,7 @@ static int mthca_init_arbel(struct mthca_dev *mdev) struct mthca_dev_lim dev_lim; struct mthca_profile profile; struct mthca_init_hca_param init_hca; - u64 icm_size; + s64 icm_size; u8 status; int err; @@ -657,7 +660,7 @@ static int mthca_init_arbel(struct mthca_dev *mdev) profile.num_srq = dev_lim.max_srqs; icm_size = mthca_make_profile(mdev, &profile, &dev_lim, &init_hca); - if ((int) icm_size < 0) { + if (icm_size < 0) { err = icm_size; goto err_stop_fw; } diff --git a/drivers/infiniband/hw/mthca/mthca_profile.c b/drivers/infiniband/hw/mthca/mthca_profile.c index 26bf86d1cfc..605a8d57fac 100644 --- a/drivers/infiniband/hw/mthca/mthca_profile.c +++ b/drivers/infiniband/hw/mthca/mthca_profile.c @@ -63,7 +63,7 @@ enum { MTHCA_NUM_PDS = 1 << 15 }; -u64 mthca_make_profile(struct mthca_dev *dev, +s64 mthca_make_profile(struct mthca_dev *dev, struct mthca_profile *request, struct mthca_dev_lim *dev_lim, struct mthca_init_hca_param *init_hca) @@ -77,7 +77,7 @@ u64 mthca_make_profile(struct mthca_dev *dev, }; u64 mem_base, mem_avail; - u64 total_size = 0; + s64 total_size = 0; struct mthca_resource *profile; struct mthca_resource tmp; int i, j; diff --git a/drivers/infiniband/hw/mthca/mthca_profile.h b/drivers/infiniband/hw/mthca/mthca_profile.h index 94641808f97..e76cb62d8e3 100644 --- a/drivers/infiniband/hw/mthca/mthca_profile.h +++ b/drivers/infiniband/hw/mthca/mthca_profile.h @@ -53,7 +53,7 @@ struct mthca_profile { int fmr_reserved_mtts; }; -u64 mthca_make_profile(struct mthca_dev *mdev, +s64 mthca_make_profile(struct mthca_dev *mdev, struct mthca_profile *request, struct mthca_dev_lim *dev_lim, struct mthca_init_hca_param *init_hca); -- cgit v1.2.3-70-g09d2 From c263ff65d5936113cfcbb8139d34122361e2306e Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Wed, 16 Apr 2008 21:01:13 -0700 Subject: IB/mthca: Avoid integer overflow when allocating huge ICM table In mthca_alloc_icm_table(), the number of entries to allocate for the table->icm array is computed by calculating obj_size * nobj and then dividing by MTHCA_TABLE_CHUNK_SIZE. If nobj is really large, then obj_size * nobj may overflow and the division may get the wrong value (even a negative value). Fix this by calculating the number of objects per chunk and then dividing nobj by this value instead. This patch allows crazy configurations such as loading ib_mthca with the module parameter num_mtt=33554432 to work properly. Signed-off-by: Roland Dreier --- drivers/infiniband/hw/mthca/mthca_memfree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/infiniband/hw/mthca') diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c index d7d502dd741..b224079d4e1 100644 --- a/drivers/infiniband/hw/mthca/mthca_memfree.c +++ b/drivers/infiniband/hw/mthca/mthca_memfree.c @@ -359,12 +359,14 @@ struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev, int use_lowmem, int use_coherent) { struct mthca_icm_table *table; + int obj_per_chunk; int num_icm; unsigned chunk_size; int i; u8 status; - num_icm = (obj_size * nobj + MTHCA_TABLE_CHUNK_SIZE - 1) / MTHCA_TABLE_CHUNK_SIZE; + obj_per_chunk = MTHCA_TABLE_CHUNK_SIZE / obj_size; + num_icm = DIV_ROUND_UP(nobj, obj_per_chunk); table = kmalloc(sizeof *table + num_icm * sizeof *table->icm, GFP_KERNEL); if (!table) -- cgit v1.2.3-70-g09d2 From b846f25aa2a353355aec5202fe4dbdc6674dfc64 Mon Sep 17 00:00:00 2001 From: Eli Cohen Date: Wed, 16 Apr 2008 21:09:27 -0700 Subject: IB/core: Add creation flags to struct ib_qp_init_attr Add a create_flags member to struct ib_qp_init_attr that will allow a kernel verbs consumer to create a pass special flags when creating a QP. Add a flag value for telling low-level drivers that a QP will be used for IPoIB UD LSO. The create_flags member will also be useful for XRC and ehca low-latency QP support. Since no create_flags handling is implemented yet, add code to all low-level drivers to return -EINVAL if create_flags is non-zero. Signed-off-by: Eli Cohen Signed-off-by: Roland Dreier --- drivers/infiniband/core/uverbs_cmd.c | 1 + drivers/infiniband/hw/amso1100/c2_provider.c | 3 +++ drivers/infiniband/hw/ehca/ehca_qp.c | 3 +++ drivers/infiniband/hw/ipath/ipath_qp.c | 5 +++++ drivers/infiniband/hw/mlx4/qp.c | 3 +++ drivers/infiniband/hw/mthca/mthca_provider.c | 3 +++ drivers/infiniband/hw/nes/nes_verbs.c | 3 +++ include/rdma/ib_verbs.h | 5 +++++ 8 files changed, 26 insertions(+) (limited to 'drivers/infiniband/hw/mthca') diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 495c803fb11..9e98cec6230 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -1065,6 +1065,7 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file, attr.srq = srq; attr.sq_sig_type = cmd.sq_sig_all ? IB_SIGNAL_ALL_WR : IB_SIGNAL_REQ_WR; attr.qp_type = cmd.qp_type; + attr.create_flags = 0; attr.cap.max_send_wr = cmd.max_send_wr; attr.cap.max_recv_wr = cmd.max_recv_wr; diff --git a/drivers/infiniband/hw/amso1100/c2_provider.c b/drivers/infiniband/hw/amso1100/c2_provider.c index 21fb46d3931..e10d27a6e14 100644 --- a/drivers/infiniband/hw/amso1100/c2_provider.c +++ b/drivers/infiniband/hw/amso1100/c2_provider.c @@ -245,6 +245,9 @@ static struct ib_qp *c2_create_qp(struct ib_pd *pd, pr_debug("%s:%u\n", __func__, __LINE__); + if (init_attr->create_flags) + return ERR_PTR(-EINVAL); + switch (init_attr->qp_type) { case IB_QPT_RC: qp = kzalloc(sizeof(*qp), GFP_KERNEL); diff --git a/drivers/infiniband/hw/ehca/ehca_qp.c b/drivers/infiniband/hw/ehca/ehca_qp.c index a9fd419855c..3eb14a52cbf 100644 --- a/drivers/infiniband/hw/ehca/ehca_qp.c +++ b/drivers/infiniband/hw/ehca/ehca_qp.c @@ -421,6 +421,9 @@ static struct ehca_qp *internal_create_qp( u32 swqe_size = 0, rwqe_size = 0, ib_qp_num; unsigned long flags; + if (init_attr->create_flags) + return ERR_PTR(-EINVAL); + memset(&parms, 0, sizeof(parms)); qp_type = init_attr->qp_type; diff --git a/drivers/infiniband/hw/ipath/ipath_qp.c b/drivers/infiniband/hw/ipath/ipath_qp.c index 6a4a5e3b78b..812b42c500e 100644 --- a/drivers/infiniband/hw/ipath/ipath_qp.c +++ b/drivers/infiniband/hw/ipath/ipath_qp.c @@ -747,6 +747,11 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd, size_t sz; struct ib_qp *ret; + if (init_attr->create_flags) { + ret = ERR_PTR(-EINVAL); + goto bail; + } + if (init_attr->cap.max_send_sge > ib_ipath_max_sges || init_attr->cap.max_send_wr > ib_ipath_max_qp_wrs) { ret = ERR_PTR(-EINVAL); diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c index 31b2b5b230b..320c25fa74b 100644 --- a/drivers/infiniband/hw/mlx4/qp.c +++ b/drivers/infiniband/hw/mlx4/qp.c @@ -673,6 +673,9 @@ struct ib_qp *mlx4_ib_create_qp(struct ib_pd *pd, struct mlx4_ib_qp *qp; int err; + if (init_attr->create_flags) + return ERR_PTR(-EINVAL); + switch (init_attr->qp_type) { case IB_QPT_RC: case IB_QPT_UC: diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c index ee9bc145622..81b257e18bb 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/drivers/infiniband/hw/mthca/mthca_provider.c @@ -540,6 +540,9 @@ static struct ib_qp *mthca_create_qp(struct ib_pd *pd, struct mthca_qp *qp; int err; + if (init_attr->create_flags) + return ERR_PTR(-EINVAL); + switch (init_attr->qp_type) { case IB_QPT_RC: case IB_QPT_UC: diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c index 46b3b8ebcc1..7c27420c224 100644 --- a/drivers/infiniband/hw/nes/nes_verbs.c +++ b/drivers/infiniband/hw/nes/nes_verbs.c @@ -1252,6 +1252,9 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd, u8 rq_encoded_size; /* int counter; */ + if (init_attr->create_flags) + return ERR_PTR(-EINVAL); + atomic_inc(&qps_created); switch (init_attr->qp_type) { case IB_QPT_RC: diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 40ff51244d1..c3299be41c6 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -495,6 +495,10 @@ enum ib_qp_type { IB_QPT_RAW_ETY }; +enum ib_qp_create_flags { + IB_QP_CREATE_IPOIB_UD_LSO = 1 << 0, +}; + struct ib_qp_init_attr { void (*event_handler)(struct ib_event *, void *); void *qp_context; @@ -504,6 +508,7 @@ struct ib_qp_init_attr { struct ib_qp_cap cap; enum ib_sig_type sq_sig_type; enum ib_qp_type qp_type; + enum ib_qp_create_flags create_flags; u8 port_num; /* special QP types only */ }; -- cgit v1.2.3-70-g09d2 From 0f39cf3d54e67a705773fd0ec56ca3dcd3e9272f Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Wed, 16 Apr 2008 21:09:32 -0700 Subject: IB/core: Add support for "send with invalidate" work requests Add a new IB_WR_SEND_WITH_INV send opcode that can be used to mark a "send with invalidate" work request as defined in the iWARP verbs and the InfiniBand base memory management extensions. Also put "imm_data" and a new "invalidate_rkey" member in a new "ex" union in struct ib_send_wr. The invalidate_rkey member can be used to pass in an R_Key/STag to be invalidated. Add this new union to struct ib_uverbs_send_wr. Add code to copy the invalidate_rkey field in ib_uverbs_post_send(). Fix up low-level drivers to deal with the change to struct ib_send_wr, and just remove the imm_data initialization from net/sunrpc/xprtrdma/, since that code never does any send with immediate operations. Also, move the existing IB_DEVICE_SEND_W_INV flag to a new bit, since the iWARP drivers currently in the tree set the bit. The amso1100 driver at least will silently fail to honor the IB_SEND_INVALIDATE bit if passed in as part of userspace send requests (since it does not implement kernel bypass work request queueing). Remove the flag from all existing drivers that set it until we know which ones are OK. The values chosen for the new flag is not consecutive to avoid clashing with flags defined in the XRC patches, which are not merged yet but which are already in use and are likely to be merged soon. This resurrects a patch sent long ago by Mikkel Hagen . Signed-off-by: Roland Dreier --- drivers/infiniband/core/uverbs_cmd.c | 13 +++++++++++-- drivers/infiniband/hw/amso1100/c2_rnic.c | 2 +- drivers/infiniband/hw/cxgb3/iwch_provider.c | 3 +-- drivers/infiniband/hw/cxgb3/iwch_qp.c | 4 ++-- drivers/infiniband/hw/ehca/ehca_reqs.c | 2 +- drivers/infiniband/hw/ipath/ipath_rc.c | 8 ++++---- drivers/infiniband/hw/ipath/ipath_ruc.c | 4 ++-- drivers/infiniband/hw/ipath/ipath_uc.c | 8 ++++---- drivers/infiniband/hw/ipath/ipath_ud.c | 4 ++-- drivers/infiniband/hw/mlx4/qp.c | 4 ++-- drivers/infiniband/hw/mthca/mthca_qp.c | 6 +++--- drivers/infiniband/hw/nes/nes_hw.c | 2 +- include/rdma/ib_user_verbs.h | 5 ++++- include/rdma/ib_verbs.h | 11 ++++++++--- net/sunrpc/xprtrdma/verbs.c | 1 - 15 files changed, 46 insertions(+), 31 deletions(-) (limited to 'drivers/infiniband/hw/mthca') diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 9e98cec6230..2c3bff5fe86 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -1463,7 +1463,6 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file, next->num_sge = user_wr->num_sge; next->opcode = user_wr->opcode; next->send_flags = user_wr->send_flags; - next->imm_data = (__be32 __force) user_wr->imm_data; if (is_ud) { next->wr.ud.ah = idr_read_ah(user_wr->wr.ud.ah, @@ -1476,14 +1475,24 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file, next->wr.ud.remote_qkey = user_wr->wr.ud.remote_qkey; } else { switch (next->opcode) { - case IB_WR_RDMA_WRITE: case IB_WR_RDMA_WRITE_WITH_IMM: + next->ex.imm_data = + (__be32 __force) user_wr->ex.imm_data; + case IB_WR_RDMA_WRITE: case IB_WR_RDMA_READ: next->wr.rdma.remote_addr = user_wr->wr.rdma.remote_addr; next->wr.rdma.rkey = user_wr->wr.rdma.rkey; break; + case IB_WR_SEND_WITH_IMM: + next->ex.imm_data = + (__be32 __force) user_wr->ex.imm_data; + break; + case IB_WR_SEND_WITH_INV: + next->ex.invalidate_rkey = + user_wr->ex.invalidate_rkey; + break; case IB_WR_ATOMIC_CMP_AND_SWP: case IB_WR_ATOMIC_FETCH_AND_ADD: next->wr.atomic.remote_addr = diff --git a/drivers/infiniband/hw/amso1100/c2_rnic.c b/drivers/infiniband/hw/amso1100/c2_rnic.c index 7a625524e0c..b1441aeb60c 100644 --- a/drivers/infiniband/hw/amso1100/c2_rnic.c +++ b/drivers/infiniband/hw/amso1100/c2_rnic.c @@ -455,7 +455,7 @@ int __devinit c2_rnic_init(struct c2_dev *c2dev) IB_DEVICE_CURR_QP_STATE_MOD | IB_DEVICE_SYS_IMAGE_GUID | IB_DEVICE_ZERO_STAG | - IB_DEVICE_SEND_W_INV | IB_DEVICE_MEM_WINDOW); + IB_DEVICE_MEM_WINDOW); /* Allocate the qptr_array */ c2dev->qptr_array = vmalloc(C2_MAX_CQS * sizeof(void *)); diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c index 50e1f2a16e0..ca7265443c0 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_provider.c +++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c @@ -1109,8 +1109,7 @@ int iwch_register_device(struct iwch_dev *dev) memcpy(&dev->ibdev.node_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6); dev->ibdev.owner = THIS_MODULE; dev->device_cap_flags = - (IB_DEVICE_ZERO_STAG | - IB_DEVICE_SEND_W_INV | IB_DEVICE_MEM_WINDOW); + (IB_DEVICE_ZERO_STAG | IB_DEVICE_MEM_WINDOW); dev->ibdev.uverbs_cmd_mask = (1ull << IB_USER_VERBS_CMD_GET_CONTEXT) | diff --git a/drivers/infiniband/hw/cxgb3/iwch_qp.c b/drivers/infiniband/hw/cxgb3/iwch_qp.c index bc5d9b0813e..8891c3b0a3d 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_qp.c +++ b/drivers/infiniband/hw/cxgb3/iwch_qp.c @@ -72,7 +72,7 @@ static int iwch_build_rdma_send(union t3_wr *wqe, struct ib_send_wr *wr, wqe->send.reserved[2] = 0; if (wr->opcode == IB_WR_SEND_WITH_IMM) { plen = 4; - wqe->send.sgl[0].stag = wr->imm_data; + wqe->send.sgl[0].stag = wr->ex.imm_data; wqe->send.sgl[0].len = __constant_cpu_to_be32(0); wqe->send.num_sgle = __constant_cpu_to_be32(0); *flit_cnt = 5; @@ -112,7 +112,7 @@ static int iwch_build_rdma_write(union t3_wr *wqe, struct ib_send_wr *wr, if (wr->opcode == IB_WR_RDMA_WRITE_WITH_IMM) { plen = 4; - wqe->write.sgl[0].stag = wr->imm_data; + wqe->write.sgl[0].stag = wr->ex.imm_data; wqe->write.sgl[0].len = __constant_cpu_to_be32(0); wqe->write.num_sgle = __constant_cpu_to_be32(0); *flit_cnt = 6; diff --git a/drivers/infiniband/hw/ehca/ehca_reqs.c b/drivers/infiniband/hw/ehca/ehca_reqs.c index 2ce8cffb866..a20bbf46618 100644 --- a/drivers/infiniband/hw/ehca/ehca_reqs.c +++ b/drivers/infiniband/hw/ehca/ehca_reqs.c @@ -188,7 +188,7 @@ static inline int ehca_write_swqe(struct ehca_qp *qp, if (send_wr->opcode == IB_WR_SEND_WITH_IMM || send_wr->opcode == IB_WR_RDMA_WRITE_WITH_IMM) { /* this might not work as long as HW does not support it */ - wqe_p->immediate_data = be32_to_cpu(send_wr->imm_data); + wqe_p->immediate_data = be32_to_cpu(send_wr->ex.imm_data); wqe_p->wr_flag |= WQE_WRFLAG_IMM_DATA_PRESENT; } diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c index 467981905bb..c405dfba553 100644 --- a/drivers/infiniband/hw/ipath/ipath_rc.c +++ b/drivers/infiniband/hw/ipath/ipath_rc.c @@ -308,7 +308,7 @@ int ipath_make_rc_req(struct ipath_qp *qp) else { qp->s_state = OP(SEND_ONLY_WITH_IMMEDIATE); /* Immediate data comes after the BTH */ - ohdr->u.imm_data = wqe->wr.imm_data; + ohdr->u.imm_data = wqe->wr.ex.imm_data; hwords += 1; } if (wqe->wr.send_flags & IB_SEND_SOLICITED) @@ -346,7 +346,7 @@ int ipath_make_rc_req(struct ipath_qp *qp) qp->s_state = OP(RDMA_WRITE_ONLY_WITH_IMMEDIATE); /* Immediate data comes after RETH */ - ohdr->u.rc.imm_data = wqe->wr.imm_data; + ohdr->u.rc.imm_data = wqe->wr.ex.imm_data; hwords += 1; if (wqe->wr.send_flags & IB_SEND_SOLICITED) bth0 |= 1 << 23; @@ -490,7 +490,7 @@ int ipath_make_rc_req(struct ipath_qp *qp) else { qp->s_state = OP(SEND_LAST_WITH_IMMEDIATE); /* Immediate data comes after the BTH */ - ohdr->u.imm_data = wqe->wr.imm_data; + ohdr->u.imm_data = wqe->wr.ex.imm_data; hwords += 1; } if (wqe->wr.send_flags & IB_SEND_SOLICITED) @@ -526,7 +526,7 @@ int ipath_make_rc_req(struct ipath_qp *qp) else { qp->s_state = OP(RDMA_WRITE_LAST_WITH_IMMEDIATE); /* Immediate data comes after the BTH */ - ohdr->u.imm_data = wqe->wr.imm_data; + ohdr->u.imm_data = wqe->wr.ex.imm_data; hwords += 1; if (wqe->wr.send_flags & IB_SEND_SOLICITED) bth0 |= 1 << 23; diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c index bcaa2914e34..8ac5c1d82cc 100644 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c @@ -310,7 +310,7 @@ again: switch (wqe->wr.opcode) { case IB_WR_SEND_WITH_IMM: wc.wc_flags = IB_WC_WITH_IMM; - wc.imm_data = wqe->wr.imm_data; + wc.imm_data = wqe->wr.ex.imm_data; /* FALLTHROUGH */ case IB_WR_SEND: if (!ipath_get_rwqe(qp, 0)) { @@ -339,7 +339,7 @@ again: goto err; } wc.wc_flags = IB_WC_WITH_IMM; - wc.imm_data = wqe->wr.imm_data; + wc.imm_data = wqe->wr.ex.imm_data; if (!ipath_get_rwqe(qp, 1)) goto rnr_nak; /* FALLTHROUGH */ diff --git a/drivers/infiniband/hw/ipath/ipath_uc.c b/drivers/infiniband/hw/ipath/ipath_uc.c index 2dd8de20d22..bfe8926b551 100644 --- a/drivers/infiniband/hw/ipath/ipath_uc.c +++ b/drivers/infiniband/hw/ipath/ipath_uc.c @@ -94,7 +94,7 @@ int ipath_make_uc_req(struct ipath_qp *qp) qp->s_state = OP(SEND_ONLY_WITH_IMMEDIATE); /* Immediate data comes after the BTH */ - ohdr->u.imm_data = wqe->wr.imm_data; + ohdr->u.imm_data = wqe->wr.ex.imm_data; hwords += 1; } if (wqe->wr.send_flags & IB_SEND_SOLICITED) @@ -123,7 +123,7 @@ int ipath_make_uc_req(struct ipath_qp *qp) qp->s_state = OP(RDMA_WRITE_ONLY_WITH_IMMEDIATE); /* Immediate data comes after the RETH */ - ohdr->u.rc.imm_data = wqe->wr.imm_data; + ohdr->u.rc.imm_data = wqe->wr.ex.imm_data; hwords += 1; if (wqe->wr.send_flags & IB_SEND_SOLICITED) bth0 |= 1 << 23; @@ -152,7 +152,7 @@ int ipath_make_uc_req(struct ipath_qp *qp) else { qp->s_state = OP(SEND_LAST_WITH_IMMEDIATE); /* Immediate data comes after the BTH */ - ohdr->u.imm_data = wqe->wr.imm_data; + ohdr->u.imm_data = wqe->wr.ex.imm_data; hwords += 1; } if (wqe->wr.send_flags & IB_SEND_SOLICITED) @@ -177,7 +177,7 @@ int ipath_make_uc_req(struct ipath_qp *qp) qp->s_state = OP(RDMA_WRITE_LAST_WITH_IMMEDIATE); /* Immediate data comes after the BTH */ - ohdr->u.imm_data = wqe->wr.imm_data; + ohdr->u.imm_data = wqe->wr.ex.imm_data; hwords += 1; if (wqe->wr.send_flags & IB_SEND_SOLICITED) bth0 |= 1 << 23; diff --git a/drivers/infiniband/hw/ipath/ipath_ud.c b/drivers/infiniband/hw/ipath/ipath_ud.c index 918f5207065..8b6a261c89e 100644 --- a/drivers/infiniband/hw/ipath/ipath_ud.c +++ b/drivers/infiniband/hw/ipath/ipath_ud.c @@ -95,7 +95,7 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe) if (swqe->wr.opcode == IB_WR_SEND_WITH_IMM) { wc.wc_flags = IB_WC_WITH_IMM; - wc.imm_data = swqe->wr.imm_data; + wc.imm_data = swqe->wr.ex.imm_data; } else { wc.wc_flags = 0; wc.imm_data = 0; @@ -327,7 +327,7 @@ int ipath_make_ud_req(struct ipath_qp *qp) } if (wqe->wr.opcode == IB_WR_SEND_WITH_IMM) { qp->s_hdrwords++; - ohdr->u.ud.imm_data = wqe->wr.imm_data; + ohdr->u.ud.imm_data = wqe->wr.ex.imm_data; bth0 = IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE << 24; } else bth0 = IB_OPCODE_UD_SEND_ONLY << 24; diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c index f5210c17e31..38e651a6758 100644 --- a/drivers/infiniband/hw/mlx4/qp.c +++ b/drivers/infiniband/hw/mlx4/qp.c @@ -1249,7 +1249,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr, case IB_WR_SEND_WITH_IMM: sqp->ud_header.bth.opcode = IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE; sqp->ud_header.immediate_present = 1; - sqp->ud_header.immediate_data = wr->imm_data; + sqp->ud_header.immediate_data = wr->ex.imm_data; break; default: return -EINVAL; @@ -1492,7 +1492,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, if (wr->opcode == IB_WR_SEND_WITH_IMM || wr->opcode == IB_WR_RDMA_WRITE_WITH_IMM) - ctrl->imm = wr->imm_data; + ctrl->imm = wr->ex.imm_data; else ctrl->imm = 0; diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index 8433897624b..b3fd6b05d79 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c @@ -1532,7 +1532,7 @@ static int build_mlx_header(struct mthca_dev *dev, struct mthca_sqp *sqp, case IB_WR_SEND_WITH_IMM: sqp->ud_header.bth.opcode = IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE; sqp->ud_header.immediate_present = 1; - sqp->ud_header.immediate_data = wr->imm_data; + sqp->ud_header.immediate_data = wr->ex.imm_data; break; default: return -EINVAL; @@ -1679,7 +1679,7 @@ int mthca_tavor_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, cpu_to_be32(1); if (wr->opcode == IB_WR_SEND_WITH_IMM || wr->opcode == IB_WR_RDMA_WRITE_WITH_IMM) - ((struct mthca_next_seg *) wqe)->imm = wr->imm_data; + ((struct mthca_next_seg *) wqe)->imm = wr->ex.imm_data; wqe += sizeof (struct mthca_next_seg); size = sizeof (struct mthca_next_seg) / 16; @@ -2020,7 +2020,7 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, cpu_to_be32(1); if (wr->opcode == IB_WR_SEND_WITH_IMM || wr->opcode == IB_WR_RDMA_WRITE_WITH_IMM) - ((struct mthca_next_seg *) wqe)->imm = wr->imm_data; + ((struct mthca_next_seg *) wqe)->imm = wr->ex.imm_data; wqe += sizeof (struct mthca_next_seg); size = sizeof (struct mthca_next_seg) / 16; diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c index 134189d77ed..aa53aab91bf 100644 --- a/drivers/infiniband/hw/nes/nes_hw.c +++ b/drivers/infiniband/hw/nes/nes_hw.c @@ -393,7 +393,7 @@ struct nes_adapter *nes_init_adapter(struct nes_device *nesdev, u8 hw_rev) { nesadapter->base_pd = 1; nesadapter->device_cap_flags = - IB_DEVICE_ZERO_STAG | IB_DEVICE_SEND_W_INV | IB_DEVICE_MEM_WINDOW; + IB_DEVICE_ZERO_STAG | IB_DEVICE_MEM_WINDOW; nesadapter->allocated_qps = (unsigned long *)&(((unsigned char *)nesadapter) [(sizeof(struct nes_adapter)+(sizeof(unsigned long)-1))&(~(sizeof(unsigned long)-1))]); diff --git a/include/rdma/ib_user_verbs.h b/include/rdma/ib_user_verbs.h index 64a721fcbc1..8d65bf0a625 100644 --- a/include/rdma/ib_user_verbs.h +++ b/include/rdma/ib_user_verbs.h @@ -533,7 +533,10 @@ struct ib_uverbs_send_wr { __u32 num_sge; __u32 opcode; __u32 send_flags; - __u32 imm_data; + union { + __u32 imm_data; + __u32 invalidate_rkey; + } ex; union { struct { __u64 remote_addr; diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 66928e9cab1..c48f6af5ef9 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -94,7 +94,7 @@ enum ib_device_cap_flags { IB_DEVICE_SRQ_RESIZE = (1<<13), IB_DEVICE_N_NOTIFY_CQ = (1<<14), IB_DEVICE_ZERO_STAG = (1<<15), - IB_DEVICE_SEND_W_INV = (1<<16), + IB_DEVICE_RESERVED = (1<<16), /* old SEND_W_INV */ IB_DEVICE_MEM_WINDOW = (1<<17), /* * Devices should set IB_DEVICE_UD_IP_SUM if they support @@ -105,6 +105,7 @@ enum ib_device_cap_flags { */ IB_DEVICE_UD_IP_CSUM = (1<<18), IB_DEVICE_UD_TSO = (1<<19), + IB_DEVICE_SEND_W_INV = (1<<21), }; enum ib_atomic_cap { @@ -625,7 +626,8 @@ enum ib_wr_opcode { IB_WR_RDMA_READ, IB_WR_ATOMIC_CMP_AND_SWP, IB_WR_ATOMIC_FETCH_AND_ADD, - IB_WR_LSO + IB_WR_LSO, + IB_WR_SEND_WITH_INV, }; enum ib_send_flags { @@ -649,7 +651,10 @@ struct ib_send_wr { int num_sge; enum ib_wr_opcode opcode; int send_flags; - __be32 imm_data; + union { + __be32 imm_data; + u32 invalidate_rkey; + } ex; union { struct { u64 remote_addr; diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c index ffbf22a1d2c..8ea283ecc52 100644 --- a/net/sunrpc/xprtrdma/verbs.c +++ b/net/sunrpc/xprtrdma/verbs.c @@ -1573,7 +1573,6 @@ rpcrdma_ep_post(struct rpcrdma_ia *ia, send_wr.sg_list = req->rl_send_iov; send_wr.num_sge = req->rl_niovs; send_wr.opcode = IB_WR_SEND; - send_wr.imm_data = 0; if (send_wr.num_sge == 4) /* no need to sync any pad (constant) */ ib_dma_sync_single_for_device(ia->ri_id->device, req->rl_send_iov[3].addr, req->rl_send_iov[3].length, -- cgit v1.2.3-70-g09d2 From 5121df3ae45731ce98374a1b0b4d48f072643f42 Mon Sep 17 00:00:00 2001 From: Dotan Barak Date: Wed, 16 Apr 2008 21:09:34 -0700 Subject: IB/mthca: Update QP state if query QP succeeds If the QP was moved to another state (such as SQE) by the hardware, then after this change the user won't have to set the IBV_QP_CUR_STATE mask in order to execute modify QP in order to recover from this state. Signed-off-by: Dotan Barak Signed-off-by: Roland Dreier --- drivers/infiniband/hw/mthca/mthca_qp.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'drivers/infiniband/hw/mthca') diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index b3fd6b05d79..09dc3614cf2 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c @@ -437,29 +437,34 @@ int mthca_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_m int mthca_state; u8 status; + mutex_lock(&qp->mutex); + if (qp->state == IB_QPS_RESET) { qp_attr->qp_state = IB_QPS_RESET; goto done; } mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); - if (IS_ERR(mailbox)) - return PTR_ERR(mailbox); + if (IS_ERR(mailbox)) { + err = PTR_ERR(mailbox); + goto out; + } err = mthca_QUERY_QP(dev, qp->qpn, 0, mailbox, &status); if (err) - goto out; + goto out_mailbox; if (status) { mthca_warn(dev, "QUERY_QP returned status %02x\n", status); err = -EINVAL; - goto out; + goto out_mailbox; } qp_param = mailbox->buf; context = &qp_param->context; mthca_state = be32_to_cpu(context->flags) >> 28; - qp_attr->qp_state = to_ib_qp_state(mthca_state); + qp->state = to_ib_qp_state(mthca_state); + qp_attr->qp_state = qp->state; qp_attr->path_mtu = context->mtu_msgmax >> 5; qp_attr->path_mig_state = to_ib_mig_state((be32_to_cpu(context->flags) >> 11) & 0x3); @@ -506,8 +511,11 @@ done: qp_init_attr->cap = qp_attr->cap; -out: +out_mailbox: mthca_free_mailbox(dev, mailbox); + +out: + mutex_unlock(&qp->mutex); return err; } -- cgit v1.2.3-70-g09d2 From 940801b27e021b3494a44bc93be3c73fadbe4c2f Mon Sep 17 00:00:00 2001 From: Jack Morgenstein Date: Wed, 16 Apr 2008 21:09:34 -0700 Subject: IB/mthca: Update module version and release date The ib_mthca driver has been stable for a while, so bump the version number to 1.0 to indicate this. Signed-off-by: Jack Morgenstein Signed-off-by: Roland Dreier --- drivers/infiniband/hw/mthca/mthca_dev.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/infiniband/hw/mthca') diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h b/drivers/infiniband/hw/mthca/mthca_dev.h index f82ed832ad9..0e842e02340 100644 --- a/drivers/infiniband/hw/mthca/mthca_dev.h +++ b/drivers/infiniband/hw/mthca/mthca_dev.h @@ -54,8 +54,8 @@ #define DRV_NAME "ib_mthca" #define PFX DRV_NAME ": " -#define DRV_VERSION "0.08" -#define DRV_RELDATE "February 14, 2006" +#define DRV_VERSION "1.0" +#define DRV_RELDATE "April 4, 2008" enum { MTHCA_FLAG_DDR_HIDDEN = 1 << 1, -- cgit v1.2.3-70-g09d2 From 6188e10d38b8d7244ee7776d5f1f88c837b4b93f Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Fri, 18 Apr 2008 22:21:05 -0400 Subject: Convert asm/semaphore.h users to linux/semaphore.h Signed-off-by: Matthew Wilcox --- Documentation/DocBook/kernel-locking.tmpl | 6 +++--- arch/ia64/kernel/salinfo.c | 2 +- drivers/base/core.c | 2 +- drivers/char/snsc.h | 2 +- drivers/firewire/fw-device.c | 3 ++- drivers/i2c/i2c-core.c | 2 +- drivers/ieee1394/nodemgr.c | 2 +- drivers/infiniband/core/user_mad.c | 2 +- drivers/infiniband/hw/mthca/mthca_dev.h | 3 +-- drivers/input/serio/hp_sdc_mlc.c | 2 +- drivers/macintosh/adb.c | 2 +- drivers/macintosh/windfarm_smu_sat.c | 2 +- drivers/net/3c527.c | 2 +- drivers/net/hamradio/6pack.c | 2 +- drivers/s390/cio/qdio.c | 2 +- drivers/scsi/aacraid/commctrl.c | 2 +- drivers/scsi/aacraid/commsup.c | 2 +- drivers/scsi/aacraid/dpcsup.c | 2 +- drivers/scsi/megaraid/megaraid_ioctl.h | 2 +- drivers/scsi/qla2xxx/qla_def.h | 2 +- drivers/watchdog/sc1200wdt.c | 2 +- fs/jffs2/jffs2_fs_i.h | 2 +- fs/jffs2/jffs2_fs_sb.h | 2 +- fs/reiserfs/journal.c | 2 +- fs/xfs/linux-2.6/sema.h | 2 +- include/linux/device.h | 2 +- include/linux/fs.h | 2 +- include/linux/hil_mlc.h | 2 +- include/linux/i2o.h | 2 +- include/linux/memory.h | 3 +-- include/linux/parport.h | 2 +- lib/kernel_lock.c | 2 +- 32 files changed, 35 insertions(+), 36 deletions(-) (limited to 'drivers/infiniband/hw/mthca') diff --git a/Documentation/DocBook/kernel-locking.tmpl b/Documentation/DocBook/kernel-locking.tmpl index 2e9d6b41f03..435413ca40d 100644 --- a/Documentation/DocBook/kernel-locking.tmpl +++ b/Documentation/DocBook/kernel-locking.tmpl @@ -241,7 +241,7 @@ The third type is a semaphore - (include/asm/semaphore.h): it + (include/linux/semaphore.h): it can have more than one holder at any time (the number decided at initialization time), although it is most commonly used as a single-holder lock (a mutex). If you can't get a semaphore, your @@ -290,7 +290,7 @@ If you have a data structure which is only ever accessed from user context, then you can use a simple semaphore - (linux/asm/semaphore.h) to protect it. This + (linux/linux/semaphore.h) to protect it. This is the most trivial case: you initialize the semaphore to the number of resources available (usually 1), and call down_interruptible() to grab the semaphore, and @@ -1656,7 +1656,7 @@ the amount of locking which needs to be done. #include <linux/slab.h> #include <linux/string.h> +#include <linux/rcupdate.h> - #include <asm/semaphore.h> + #include <linux/semaphore.h> #include <asm/errno.h> struct object diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c index 779c3cca206..b11bb50a197 100644 --- a/arch/ia64/kernel/salinfo.c +++ b/arch/ia64/kernel/salinfo.c @@ -44,8 +44,8 @@ #include #include #include +#include -#include #include #include diff --git a/drivers/base/core.c b/drivers/base/core.c index 24198ad0197..7c4b36ccb1a 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include "base.h" #include "power/power.h" diff --git a/drivers/char/snsc.h b/drivers/char/snsc.h index 8a98169b60c..4be62eda9fb 100644 --- a/drivers/char/snsc.h +++ b/drivers/char/snsc.h @@ -22,8 +22,8 @@ #include #include #include +#include #include -#include #define CHUNKSIZE 127 diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c index 2d01bc1b975..d9c8daf7ae7 100644 --- a/drivers/firewire/fw-device.c +++ b/drivers/firewire/fw-device.c @@ -26,7 +26,8 @@ #include #include #include -#include +#include +#include #include #include #include "fw-transaction.h" diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 8b645c6b2cb..e186df65711 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -35,8 +35,8 @@ #include #include #include +#include #include -#include #include "i2c-core.h" diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c index 70afa3786f3..29d833e71cb 100644 --- a/drivers/ieee1394/nodemgr.c +++ b/drivers/ieee1394/nodemgr.c @@ -18,8 +18,8 @@ #include #include #include +#include #include -#include #include "csr.h" #include "highlevel.h" diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c index 4e915104ac4..be953e87bf9 100644 --- a/drivers/infiniband/core/user_mad.c +++ b/drivers/infiniband/core/user_mad.c @@ -46,9 +46,9 @@ #include #include #include +#include #include -#include #include #include diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h b/drivers/infiniband/hw/mthca/mthca_dev.h index 0e842e02340..7bc32f8e377 100644 --- a/drivers/infiniband/hw/mthca/mthca_dev.h +++ b/drivers/infiniband/hw/mthca/mthca_dev.h @@ -46,8 +46,7 @@ #include #include #include - -#include +#include #include "mthca_provider.h" #include "mthca_doorbell.h" diff --git a/drivers/input/serio/hp_sdc_mlc.c b/drivers/input/serio/hp_sdc_mlc.c index c45ea74d53e..f1fd3b638a3 100644 --- a/drivers/input/serio/hp_sdc_mlc.c +++ b/drivers/input/serio/hp_sdc_mlc.c @@ -40,7 +40,7 @@ #include #include #include -#include +#include #define PREFIX "HP SDC MLC: " diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c index 28958101061..20978205cd0 100644 --- a/drivers/macintosh/adb.c +++ b/drivers/macintosh/adb.c @@ -37,9 +37,9 @@ #include #include #include +#include #include -#include #ifdef CONFIG_PPC #include #include diff --git a/drivers/macintosh/windfarm_smu_sat.c b/drivers/macintosh/windfarm_smu_sat.c index f449d775cdf..797918d0e59 100644 --- a/drivers/macintosh/windfarm_smu_sat.c +++ b/drivers/macintosh/windfarm_smu_sat.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/drivers/net/3c527.c b/drivers/net/3c527.c index b72b89d53ec..fae295b6809 100644 --- a/drivers/net/3c527.c +++ b/drivers/net/3c527.c @@ -103,8 +103,8 @@ DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " Richard Procter #include #include +#include -#include #include #include #include diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c index 0a9b75139e0..1da55dd2a5a 100644 --- a/drivers/net/hamradio/6pack.c +++ b/drivers/net/hamradio/6pack.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #define SIXPACK_VERSION "Revision: 0.3.0" diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c index c359386708e..10aa1e78080 100644 --- a/drivers/s390/cio/qdio.c +++ b/drivers/s390/cio/qdio.c @@ -38,11 +38,11 @@ #include #include #include +#include #include #include #include -#include #include #include diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c index abef05146d7..5fd83deab36 100644 --- a/drivers/scsi/aacraid/commctrl.c +++ b/drivers/scsi/aacraid/commctrl.c @@ -39,7 +39,7 @@ #include #include /* ssleep prototype */ #include -#include +#include #include #include "aacraid.h" diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index 23a8e9f8dcb..ef67816a6fe 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -41,11 +41,11 @@ #include #include #include +#include #include #include #include #include -#include #include "aacraid.h" diff --git a/drivers/scsi/aacraid/dpcsup.c b/drivers/scsi/aacraid/dpcsup.c index d1163ded132..933f208eedb 100644 --- a/drivers/scsi/aacraid/dpcsup.c +++ b/drivers/scsi/aacraid/dpcsup.c @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include "aacraid.h" diff --git a/drivers/scsi/megaraid/megaraid_ioctl.h b/drivers/scsi/megaraid/megaraid_ioctl.h index 706fa05a187..05f6e4ec345 100644 --- a/drivers/scsi/megaraid/megaraid_ioctl.h +++ b/drivers/scsi/megaraid/megaraid_ioctl.h @@ -18,7 +18,7 @@ #define _MEGARAID_IOCTL_H_ #include -#include +#include #include "mbox_defs.h" diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 094d95f0764..299eccf6cab 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/drivers/watchdog/sc1200wdt.c b/drivers/watchdog/sc1200wdt.c index 32ccd7c89c7..35cddff7020 100644 --- a/drivers/watchdog/sc1200wdt.c +++ b/drivers/watchdog/sc1200wdt.c @@ -38,8 +38,8 @@ #include #include #include +#include -#include #include #include diff --git a/fs/jffs2/jffs2_fs_i.h b/fs/jffs2/jffs2_fs_i.h index 0b78fdc9773..a841f4973a7 100644 --- a/fs/jffs2/jffs2_fs_i.h +++ b/fs/jffs2/jffs2_fs_i.h @@ -15,7 +15,7 @@ #include #include #include -#include +#include struct jffs2_inode_info { /* We need an internal mutex similar to inode->i_mutex. diff --git a/fs/jffs2/jffs2_fs_sb.h b/fs/jffs2/jffs2_fs_sb.h index 3a2197f3c81..18fca2b9e53 100644 --- a/fs/jffs2/jffs2_fs_sb.h +++ b/fs/jffs2/jffs2_fs_sb.h @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c index bb05a3e51b9..060eb3f598e 100644 --- a/fs/reiserfs/journal.c +++ b/fs/reiserfs/journal.c @@ -38,7 +38,7 @@ #include #include -#include +#include #include #include diff --git a/fs/xfs/linux-2.6/sema.h b/fs/xfs/linux-2.6/sema.h index 2009e6d922c..3abe7e9ceb3 100644 --- a/fs/xfs/linux-2.6/sema.h +++ b/fs/xfs/linux-2.6/sema.h @@ -20,8 +20,8 @@ #include #include +#include #include -#include /* * sema_t structure just maps to struct semaphore in Linux kernel. diff --git a/include/linux/device.h b/include/linux/device.h index 2258d89bf52..c79b93e56fa 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include diff --git a/include/linux/fs.h b/include/linux/fs.h index b84b848431f..91e8dec9e42 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -287,9 +287,9 @@ extern int dir_notify_enable; #include #include #include +#include #include -#include #include struct export_operations; diff --git a/include/linux/hil_mlc.h b/include/linux/hil_mlc.h index 8df29ca48a1..394a8405dd7 100644 --- a/include/linux/hil_mlc.h +++ b/include/linux/hil_mlc.h @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include diff --git a/include/linux/i2o.h b/include/linux/i2o.h index 7da5b98d90e..e92170dda24 100644 --- a/include/linux/i2o.h +++ b/include/linux/i2o.h @@ -33,9 +33,9 @@ #include #include #include +#include /* Needed for MUTEX init macros */ #include -#include /* Needed for MUTEX init macros */ /* message queue empty */ #define I2O_QUEUE_EMPTY 0xffffffff diff --git a/include/linux/memory.h b/include/linux/memory.h index 33f0ff0cf63..54d7866d9c0 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -18,8 +18,7 @@ #include #include #include - -#include +#include struct memory_block { unsigned long phys_index; diff --git a/include/linux/parport.h b/include/linux/parport.h index d1ad546c8c9..dcb9e01a69c 100644 --- a/include/linux/parport.h +++ b/include/linux/parport.h @@ -101,9 +101,9 @@ typedef enum { #include #include #include +#include #include #include -#include /* Define this later. */ struct parport; diff --git a/lib/kernel_lock.c b/lib/kernel_lock.c index fbc11a336bc..cd3e82530b0 100644 --- a/lib/kernel_lock.c +++ b/lib/kernel_lock.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include /* * The 'big kernel semaphore' -- cgit v1.2.3-70-g09d2 From f4e91eb4a81559da87a3843758a641b5cc590b65 Mon Sep 17 00:00:00 2001 From: Tony Jones Date: Fri, 22 Feb 2008 00:13:36 +0100 Subject: IB: convert struct class_device to struct device This converts the main ib_device to use struct device instead of struct class_device as class_device is going away. Signed-off-by: Tony Jones Signed-off-by: Kay Sievers Cc: Roland Dreier Cc: Sean Hefty Cc: Hal Rosenstock Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/sysfs.c | 76 ++++++++++--------- drivers/infiniband/core/ucm.c | 62 +++++++-------- drivers/infiniband/core/user_mad.c | 109 ++++++++++++++------------- drivers/infiniband/core/uverbs.h | 4 +- drivers/infiniband/core/uverbs_main.c | 51 +++++++------ drivers/infiniband/hw/amso1100/c2_provider.c | 48 ++++++------ drivers/infiniband/hw/cxgb3/iwch_provider.c | 75 +++++++++--------- drivers/infiniband/hw/ipath/ipath_diag.c | 10 +-- drivers/infiniband/hw/ipath/ipath_file_ops.c | 44 +++++------ drivers/infiniband/hw/ipath/ipath_kernel.h | 8 +- drivers/infiniband/hw/ipath/ipath_verbs.c | 37 ++++----- drivers/infiniband/hw/mlx4/main.c | 49 +++++++----- drivers/infiniband/hw/mthca/mthca_provider.c | 48 +++++++----- drivers/infiniband/hw/nes/nes_verbs.c | 48 ++++++------ include/rdma/ib_verbs.h | 2 +- 15 files changed, 352 insertions(+), 319 deletions(-) (limited to 'drivers/infiniband/hw/mthca') diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index 5a4b2e65534..95756551cf7 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c @@ -427,17 +427,17 @@ static struct kobj_type port_type = { .default_attrs = port_default_attrs }; -static void ib_device_release(struct class_device *cdev) +static void ib_device_release(struct device *device) { - struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); + struct ib_device *dev = container_of(device, struct ib_device, dev); kfree(dev); } -static int ib_device_uevent(struct class_device *cdev, +static int ib_device_uevent(struct device *device, struct kobj_uevent_env *env) { - struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); + struct ib_device *dev = container_of(device, struct ib_device, dev); if (add_uevent_var(env, "NAME=%s", dev->name)) return -ENOMEM; @@ -567,9 +567,10 @@ err_put: return ret; } -static ssize_t show_node_type(struct class_device *cdev, char *buf) +static ssize_t show_node_type(struct device *device, + struct device_attribute *attr, char *buf) { - struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); + struct ib_device *dev = container_of(device, struct ib_device, dev); if (!ibdev_is_alive(dev)) return -ENODEV; @@ -583,9 +584,10 @@ static ssize_t show_node_type(struct class_device *cdev, char *buf) } } -static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf) +static ssize_t show_sys_image_guid(struct device *device, + struct device_attribute *dev_attr, char *buf) { - struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); + struct ib_device *dev = container_of(device, struct ib_device, dev); struct ib_device_attr attr; ssize_t ret; @@ -603,9 +605,10 @@ static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf) be16_to_cpu(((__be16 *) &attr.sys_image_guid)[3])); } -static ssize_t show_node_guid(struct class_device *cdev, char *buf) +static ssize_t show_node_guid(struct device *device, + struct device_attribute *attr, char *buf) { - struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); + struct ib_device *dev = container_of(device, struct ib_device, dev); if (!ibdev_is_alive(dev)) return -ENODEV; @@ -617,17 +620,19 @@ static ssize_t show_node_guid(struct class_device *cdev, char *buf) be16_to_cpu(((__be16 *) &dev->node_guid)[3])); } -static ssize_t show_node_desc(struct class_device *cdev, char *buf) +static ssize_t show_node_desc(struct device *device, + struct device_attribute *attr, char *buf) { - struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); + struct ib_device *dev = container_of(device, struct ib_device, dev); return sprintf(buf, "%.64s\n", dev->node_desc); } -static ssize_t set_node_desc(struct class_device *cdev, const char *buf, - size_t count) +static ssize_t set_node_desc(struct device *device, + struct device_attribute *attr, + const char *buf, size_t count) { - struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); + struct ib_device *dev = container_of(device, struct ib_device, dev); struct ib_device_modify desc = {}; int ret; @@ -642,44 +647,43 @@ static ssize_t set_node_desc(struct class_device *cdev, const char *buf, return count; } -static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL); -static CLASS_DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL); -static CLASS_DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL); -static CLASS_DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc, - set_node_desc); - -static struct class_device_attribute *ib_class_attributes[] = { - &class_device_attr_node_type, - &class_device_attr_sys_image_guid, - &class_device_attr_node_guid, - &class_device_attr_node_desc +static DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL); +static DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL); +static DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL); +static DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc, set_node_desc); + +static struct device_attribute *ib_class_attributes[] = { + &dev_attr_node_type, + &dev_attr_sys_image_guid, + &dev_attr_node_guid, + &dev_attr_node_desc }; static struct class ib_class = { .name = "infiniband", - .release = ib_device_release, - .uevent = ib_device_uevent, + .dev_release = ib_device_release, + .dev_uevent = ib_device_uevent, }; int ib_device_register_sysfs(struct ib_device *device) { - struct class_device *class_dev = &device->class_dev; + struct device *class_dev = &device->dev; int ret; int i; class_dev->class = &ib_class; - class_dev->class_data = device; - class_dev->dev = device->dma_device; - strlcpy(class_dev->class_id, device->name, BUS_ID_SIZE); + class_dev->driver_data = device; + class_dev->parent = device->dma_device; + strlcpy(class_dev->bus_id, device->name, BUS_ID_SIZE); INIT_LIST_HEAD(&device->port_list); - ret = class_device_register(class_dev); + ret = device_register(class_dev); if (ret) goto err; for (i = 0; i < ARRAY_SIZE(ib_class_attributes); ++i) { - ret = class_device_create_file(class_dev, ib_class_attributes[i]); + ret = device_create_file(class_dev, ib_class_attributes[i]); if (ret) goto err_unregister; } @@ -723,7 +727,7 @@ err_put: kobject_put(&class_dev->kobj); err_unregister: - class_device_unregister(class_dev); + device_unregister(class_dev); err: return ret; @@ -744,7 +748,7 @@ void ib_device_unregister_sysfs(struct ib_device *device) } kobject_put(device->ports_parent); - class_device_unregister(&device->class_dev); + device_unregister(&device->dev); } int ib_sysfs_setup(void) diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index 4291ab42a5b..d7a6881b571 100644 --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c @@ -58,8 +58,8 @@ MODULE_LICENSE("Dual BSD/GPL"); struct ib_ucm_device { int devnum; - struct cdev dev; - struct class_device class_dev; + struct cdev cdev; + struct device dev; struct ib_device *ib_dev; }; @@ -1171,7 +1171,7 @@ static int ib_ucm_open(struct inode *inode, struct file *filp) filp->private_data = file; file->filp = filp; - file->device = container_of(inode->i_cdev, struct ib_ucm_device, dev); + file->device = container_of(inode->i_cdev, struct ib_ucm_device, cdev); return 0; } @@ -1202,14 +1202,14 @@ static int ib_ucm_close(struct inode *inode, struct file *filp) return 0; } -static void ucm_release_class_dev(struct class_device *class_dev) +static void ib_ucm_release_dev(struct device *dev) { - struct ib_ucm_device *dev; + struct ib_ucm_device *ucm_dev; - dev = container_of(class_dev, struct ib_ucm_device, class_dev); - cdev_del(&dev->dev); - clear_bit(dev->devnum, dev_map); - kfree(dev); + ucm_dev = container_of(dev, struct ib_ucm_device, dev); + cdev_del(&ucm_dev->cdev); + clear_bit(ucm_dev->devnum, dev_map); + kfree(ucm_dev); } static const struct file_operations ucm_fops = { @@ -1220,14 +1220,15 @@ static const struct file_operations ucm_fops = { .poll = ib_ucm_poll, }; -static ssize_t show_ibdev(struct class_device *class_dev, char *buf) +static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr, + char *buf) { - struct ib_ucm_device *dev; + struct ib_ucm_device *ucm_dev; - dev = container_of(class_dev, struct ib_ucm_device, class_dev); - return sprintf(buf, "%s\n", dev->ib_dev->name); + ucm_dev = container_of(dev, struct ib_ucm_device, dev); + return sprintf(buf, "%s\n", ucm_dev->ib_dev->name); } -static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); +static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); static void ib_ucm_add_one(struct ib_device *device) { @@ -1249,32 +1250,31 @@ static void ib_ucm_add_one(struct ib_device *device) set_bit(ucm_dev->devnum, dev_map); - cdev_init(&ucm_dev->dev, &ucm_fops); - ucm_dev->dev.owner = THIS_MODULE; - kobject_set_name(&ucm_dev->dev.kobj, "ucm%d", ucm_dev->devnum); - if (cdev_add(&ucm_dev->dev, IB_UCM_BASE_DEV + ucm_dev->devnum, 1)) + cdev_init(&ucm_dev->cdev, &ucm_fops); + ucm_dev->cdev.owner = THIS_MODULE; + kobject_set_name(&ucm_dev->cdev.kobj, "ucm%d", ucm_dev->devnum); + if (cdev_add(&ucm_dev->cdev, IB_UCM_BASE_DEV + ucm_dev->devnum, 1)) goto err; - ucm_dev->class_dev.class = &cm_class; - ucm_dev->class_dev.dev = device->dma_device; - ucm_dev->class_dev.devt = ucm_dev->dev.dev; - ucm_dev->class_dev.release = ucm_release_class_dev; - snprintf(ucm_dev->class_dev.class_id, BUS_ID_SIZE, "ucm%d", + ucm_dev->dev.class = &cm_class; + ucm_dev->dev.parent = device->dma_device; + ucm_dev->dev.devt = ucm_dev->cdev.dev; + ucm_dev->dev.release = ib_ucm_release_dev; + snprintf(ucm_dev->dev.bus_id, BUS_ID_SIZE, "ucm%d", ucm_dev->devnum); - if (class_device_register(&ucm_dev->class_dev)) + if (device_register(&ucm_dev->dev)) goto err_cdev; - if (class_device_create_file(&ucm_dev->class_dev, - &class_device_attr_ibdev)) - goto err_class; + if (device_create_file(&ucm_dev->dev, &dev_attr_ibdev)) + goto err_dev; ib_set_client_data(device, &ucm_client, ucm_dev); return; -err_class: - class_device_unregister(&ucm_dev->class_dev); +err_dev: + device_unregister(&ucm_dev->dev); err_cdev: - cdev_del(&ucm_dev->dev); + cdev_del(&ucm_dev->cdev); clear_bit(ucm_dev->devnum, dev_map); err: kfree(ucm_dev); @@ -1288,7 +1288,7 @@ static void ib_ucm_remove_one(struct ib_device *device) if (!ucm_dev) return; - class_device_unregister(&ucm_dev->class_dev); + device_unregister(&ucm_dev->dev); } static ssize_t show_abi_version(struct class *class, char *buf) diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c index 4e915104ac4..9a9d3446c6e 100644 --- a/drivers/infiniband/core/user_mad.c +++ b/drivers/infiniband/core/user_mad.c @@ -88,11 +88,11 @@ enum { */ struct ib_umad_port { - struct cdev *dev; - struct class_device *class_dev; + struct cdev *cdev; + struct device *dev; - struct cdev *sm_dev; - struct class_device *sm_class_dev; + struct cdev *sm_cdev; + struct device *sm_dev; struct semaphore sm_sem; struct mutex file_mutex; @@ -948,27 +948,29 @@ static struct ib_client umad_client = { .remove = ib_umad_remove_one }; -static ssize_t show_ibdev(struct class_device *class_dev, char *buf) +static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr, + char *buf) { - struct ib_umad_port *port = class_get_devdata(class_dev); + struct ib_umad_port *port = dev_get_drvdata(dev); if (!port) return -ENODEV; return sprintf(buf, "%s\n", port->ib_dev->name); } -static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); +static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); -static ssize_t show_port(struct class_device *class_dev, char *buf) +static ssize_t show_port(struct device *dev, struct device_attribute *attr, + char *buf) { - struct ib_umad_port *port = class_get_devdata(class_dev); + struct ib_umad_port *port = dev_get_drvdata(dev); if (!port) return -ENODEV; return sprintf(buf, "%d\n", port->port_num); } -static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL); +static DEVICE_ATTR(port, S_IRUGO, show_port, NULL); static ssize_t show_abi_version(struct class *class, char *buf) { @@ -994,48 +996,47 @@ static int ib_umad_init_port(struct ib_device *device, int port_num, mutex_init(&port->file_mutex); INIT_LIST_HEAD(&port->file_list); - port->dev = cdev_alloc(); - if (!port->dev) + port->cdev = cdev_alloc(); + if (!port->cdev) return -1; - port->dev->owner = THIS_MODULE; - port->dev->ops = &umad_fops; - kobject_set_name(&port->dev->kobj, "umad%d", port->dev_num); - if (cdev_add(port->dev, base_dev + port->dev_num, 1)) + port->cdev->owner = THIS_MODULE; + port->cdev->ops = &umad_fops; + kobject_set_name(&port->cdev->kobj, "umad%d", port->dev_num); + if (cdev_add(port->cdev, base_dev + port->dev_num, 1)) goto err_cdev; - port->class_dev = class_device_create(umad_class, NULL, port->dev->dev, - device->dma_device, - "umad%d", port->dev_num); - if (IS_ERR(port->class_dev)) + port->dev = device_create(umad_class, device->dma_device, + port->cdev->dev, "umad%d", port->dev_num); + if (IS_ERR(port->dev)) goto err_cdev; - if (class_device_create_file(port->class_dev, &class_device_attr_ibdev)) - goto err_class; - if (class_device_create_file(port->class_dev, &class_device_attr_port)) - goto err_class; - - port->sm_dev = cdev_alloc(); - if (!port->sm_dev) - goto err_class; - port->sm_dev->owner = THIS_MODULE; - port->sm_dev->ops = &umad_sm_fops; - kobject_set_name(&port->sm_dev->kobj, "issm%d", port->dev_num); - if (cdev_add(port->sm_dev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1)) + if (device_create_file(port->dev, &dev_attr_ibdev)) + goto err_dev; + if (device_create_file(port->dev, &dev_attr_port)) + goto err_dev; + + port->sm_cdev = cdev_alloc(); + if (!port->sm_cdev) + goto err_dev; + port->sm_cdev->owner = THIS_MODULE; + port->sm_cdev->ops = &umad_sm_fops; + kobject_set_name(&port->sm_cdev->kobj, "issm%d", port->dev_num); + if (cdev_add(port->sm_cdev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1)) goto err_sm_cdev; - port->sm_class_dev = class_device_create(umad_class, NULL, port->sm_dev->dev, - device->dma_device, - "issm%d", port->dev_num); - if (IS_ERR(port->sm_class_dev)) + port->sm_dev = device_create(umad_class, device->dma_device, + port->sm_cdev->dev, + "issm%d", port->dev_num); + if (IS_ERR(port->sm_dev)) goto err_sm_cdev; - class_set_devdata(port->class_dev, port); - class_set_devdata(port->sm_class_dev, port); + dev_set_drvdata(port->dev, port); + dev_set_drvdata(port->sm_dev, port); - if (class_device_create_file(port->sm_class_dev, &class_device_attr_ibdev)) - goto err_sm_class; - if (class_device_create_file(port->sm_class_dev, &class_device_attr_port)) - goto err_sm_class; + if (device_create_file(port->sm_dev, &dev_attr_ibdev)) + goto err_sm_dev; + if (device_create_file(port->sm_dev, &dev_attr_port)) + goto err_sm_dev; spin_lock(&port_lock); umad_port[port->dev_num] = port; @@ -1043,17 +1044,17 @@ static int ib_umad_init_port(struct ib_device *device, int port_num, return 0; -err_sm_class: - class_device_destroy(umad_class, port->sm_dev->dev); +err_sm_dev: + device_destroy(umad_class, port->sm_cdev->dev); err_sm_cdev: - cdev_del(port->sm_dev); + cdev_del(port->sm_cdev); -err_class: - class_device_destroy(umad_class, port->dev->dev); +err_dev: + device_destroy(umad_class, port->cdev->dev); err_cdev: - cdev_del(port->dev); + cdev_del(port->cdev); clear_bit(port->dev_num, dev_map); return -1; @@ -1065,14 +1066,14 @@ static void ib_umad_kill_port(struct ib_umad_port *port) int already_dead; int id; - class_set_devdata(port->class_dev, NULL); - class_set_devdata(port->sm_class_dev, NULL); + dev_set_drvdata(port->dev, NULL); + dev_set_drvdata(port->sm_dev, NULL); - class_device_destroy(umad_class, port->dev->dev); - class_device_destroy(umad_class, port->sm_dev->dev); + device_destroy(umad_class, port->cdev->dev); + device_destroy(umad_class, port->sm_cdev->dev); - cdev_del(port->dev); - cdev_del(port->sm_dev); + cdev_del(port->cdev); + cdev_del(port->sm_cdev); spin_lock(&port_lock); umad_port[port->dev_num] = NULL; diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h index 2cad8b4b529..376a57ce1b4 100644 --- a/drivers/infiniband/core/uverbs.h +++ b/drivers/infiniband/core/uverbs.h @@ -73,8 +73,8 @@ struct ib_uverbs_device { struct kref ref; struct completion comp; int devnum; - struct cdev *dev; - struct class_device *class_dev; + struct cdev *cdev; + struct device *dev; struct ib_device *ib_dev; int num_comp_vectors; }; diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index f49f94653a9..cc1afa28c18 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c @@ -690,27 +690,29 @@ static struct ib_client uverbs_client = { .remove = ib_uverbs_remove_one }; -static ssize_t show_ibdev(struct class_device *class_dev, char *buf) +static ssize_t show_ibdev(struct device *device, struct device_attribute *attr, + char *buf) { - struct ib_uverbs_device *dev = class_get_devdata(class_dev); + struct ib_uverbs_device *dev = dev_get_drvdata(device); if (!dev) return -ENODEV; return sprintf(buf, "%s\n", dev->ib_dev->name); } -static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); +static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); -static ssize_t show_dev_abi_version(struct class_device *class_dev, char *buf) +static ssize_t show_dev_abi_version(struct device *device, + struct device_attribute *attr, char *buf) { - struct ib_uverbs_device *dev = class_get_devdata(class_dev); + struct ib_uverbs_device *dev = dev_get_drvdata(device); if (!dev) return -ENODEV; return sprintf(buf, "%d\n", dev->ib_dev->uverbs_abi_ver); } -static CLASS_DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL); +static DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL); static ssize_t show_abi_version(struct class *class, char *buf) { @@ -744,27 +746,26 @@ static void ib_uverbs_add_one(struct ib_device *device) uverbs_dev->ib_dev = device; uverbs_dev->num_comp_vectors = device->num_comp_vectors; - uverbs_dev->dev = cdev_alloc(); - if (!uverbs_dev->dev) + uverbs_dev->cdev = cdev_alloc(); + if (!uverbs_dev->cdev) goto err; - uverbs_dev->dev->owner = THIS_MODULE; - uverbs_dev->dev->ops = device->mmap ? &uverbs_mmap_fops : &uverbs_fops; - kobject_set_name(&uverbs_dev->dev->kobj, "uverbs%d", uverbs_dev->devnum); - if (cdev_add(uverbs_dev->dev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1)) + uverbs_dev->cdev->owner = THIS_MODULE; + uverbs_dev->cdev->ops = device->mmap ? &uverbs_mmap_fops : &uverbs_fops; + kobject_set_name(&uverbs_dev->cdev->kobj, "uverbs%d", uverbs_dev->devnum); + if (cdev_add(uverbs_dev->cdev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1)) goto err_cdev; - uverbs_dev->class_dev = class_device_create(uverbs_class, NULL, - uverbs_dev->dev->dev, - device->dma_device, - "uverbs%d", uverbs_dev->devnum); - if (IS_ERR(uverbs_dev->class_dev)) + uverbs_dev->dev = device_create(uverbs_class, device->dma_device, + uverbs_dev->cdev->dev, + "uverbs%d", uverbs_dev->devnum); + if (IS_ERR(uverbs_dev->dev)) goto err_cdev; - class_set_devdata(uverbs_dev->class_dev, uverbs_dev); + dev_set_drvdata(uverbs_dev->dev, uverbs_dev); - if (class_device_create_file(uverbs_dev->class_dev, &class_device_attr_ibdev)) + if (device_create_file(uverbs_dev->dev, &dev_attr_ibdev)) goto err_class; - if (class_device_create_file(uverbs_dev->class_dev, &class_device_attr_abi_version)) + if (device_create_file(uverbs_dev->dev, &dev_attr_abi_version)) goto err_class; spin_lock(&map_lock); @@ -776,10 +777,10 @@ static void ib_uverbs_add_one(struct ib_device *device) return; err_class: - class_device_destroy(uverbs_class, uverbs_dev->dev->dev); + device_destroy(uverbs_class, uverbs_dev->cdev->dev); err_cdev: - cdev_del(uverbs_dev->dev); + cdev_del(uverbs_dev->cdev); clear_bit(uverbs_dev->devnum, dev_map); err: @@ -796,9 +797,9 @@ static void ib_uverbs_remove_one(struct ib_device *device) if (!uverbs_dev) return; - class_set_devdata(uverbs_dev->class_dev, NULL); - class_device_destroy(uverbs_class, uverbs_dev->dev->dev); - cdev_del(uverbs_dev->dev); + dev_set_drvdata(uverbs_dev->dev, NULL); + device_destroy(uverbs_class, uverbs_dev->cdev->dev); + cdev_del(uverbs_dev->cdev); spin_lock(&map_lock); dev_table[uverbs_dev->devnum] = NULL; diff --git a/drivers/infiniband/hw/amso1100/c2_provider.c b/drivers/infiniband/hw/amso1100/c2_provider.c index e10d27a6e14..6af2c0f79a6 100644 --- a/drivers/infiniband/hw/amso1100/c2_provider.c +++ b/drivers/infiniband/hw/amso1100/c2_provider.c @@ -523,45 +523,49 @@ static int c2_dereg_mr(struct ib_mr *ib_mr) return err; } -static ssize_t show_rev(struct class_device *cdev, char *buf) +static ssize_t show_rev(struct device *dev, struct device_attribute *attr, + char *buf) { - struct c2_dev *dev = container_of(cdev, struct c2_dev, ibdev.class_dev); + struct c2_dev *c2dev = container_of(dev, struct c2_dev, ibdev.dev); pr_debug("%s:%u\n", __func__, __LINE__); - return sprintf(buf, "%x\n", dev->props.hw_ver); + return sprintf(buf, "%x\n", c2dev->props.hw_ver); } -static ssize_t show_fw_ver(struct class_device *cdev, char *buf) +static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, + char *buf) { - struct c2_dev *dev = container_of(cdev, struct c2_dev, ibdev.class_dev); + struct c2_dev *c2dev = container_of(dev, struct c2_dev, ibdev.dev); pr_debug("%s:%u\n", __func__, __LINE__); return sprintf(buf, "%x.%x.%x\n", - (int) (dev->props.fw_ver >> 32), - (int) (dev->props.fw_ver >> 16) & 0xffff, - (int) (dev->props.fw_ver & 0xffff)); + (int) (c2dev->props.fw_ver >> 32), + (int) (c2dev->props.fw_ver >> 16) & 0xffff, + (int) (c2dev->props.fw_ver & 0xffff)); } -static ssize_t show_hca(struct class_device *cdev, char *buf) +static ssize_t show_hca(struct device *dev, struct device_attribute *attr, + char *buf) { pr_debug("%s:%u\n", __func__, __LINE__); return sprintf(buf, "AMSO1100\n"); } -static ssize_t show_board(struct class_device *cdev, char *buf) +static ssize_t show_board(struct device *dev, struct device_attribute *attr, + char *buf) { pr_debug("%s:%u\n", __func__, __LINE__); return sprintf(buf, "%.*s\n", 32, "AMSO1100 Board ID"); } -static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); -static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); -static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); -static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); +static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); +static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); +static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); +static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); -static struct class_device_attribute *c2_class_attributes[] = { - &class_device_attr_hw_rev, - &class_device_attr_fw_ver, - &class_device_attr_hca_type, - &class_device_attr_board_id +static struct device_attribute *c2_dev_attributes[] = { + &dev_attr_hw_rev, + &dev_attr_fw_ver, + &dev_attr_hca_type, + &dev_attr_board_id }; static int c2_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, @@ -861,9 +865,9 @@ int c2_register_device(struct c2_dev *dev) if (ret) goto out1; - for (i = 0; i < ARRAY_SIZE(c2_class_attributes); ++i) { - ret = class_device_create_file(&dev->ibdev.class_dev, - c2_class_attributes[i]); + for (i = 0; i < ARRAY_SIZE(c2_dev_attributes); ++i) { + ret = device_create_file(&dev->ibdev.dev, + c2_dev_attributes[i]); if (ret) goto out0; } diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c index ca7265443c0..ab4695c1dd5 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_provider.c +++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c @@ -1041,61 +1041,60 @@ static int iwch_query_port(struct ib_device *ibdev, return 0; } -static ssize_t show_rev(struct class_device *cdev, char *buf) +static ssize_t show_rev(struct device *dev, struct device_attribute *attr, + char *buf) { - struct iwch_dev *dev = container_of(cdev, struct iwch_dev, - ibdev.class_dev); - PDBG("%s class dev 0x%p\n", __func__, cdev); - return sprintf(buf, "%d\n", dev->rdev.t3cdev_p->type); + struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev, + ibdev.dev); + PDBG("%s dev 0x%p\n", __func__, dev); + return sprintf(buf, "%d\n", iwch_dev->rdev.t3cdev_p->type); } -static ssize_t show_fw_ver(struct class_device *cdev, char *buf) +static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, char *buf) { - struct iwch_dev *dev = container_of(cdev, struct iwch_dev, - ibdev.class_dev); + struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev, + ibdev.dev); struct ethtool_drvinfo info; - struct net_device *lldev = dev->rdev.t3cdev_p->lldev; + struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev; - PDBG("%s class dev 0x%p\n", __func__, cdev); - rtnl_lock(); + PDBG("%s dev 0x%p\n", __func__, dev); lldev->ethtool_ops->get_drvinfo(lldev, &info); - rtnl_unlock(); return sprintf(buf, "%s\n", info.fw_version); } -static ssize_t show_hca(struct class_device *cdev, char *buf) +static ssize_t show_hca(struct device *dev, struct device_attribute *attr, + char *buf) { - struct iwch_dev *dev = container_of(cdev, struct iwch_dev, - ibdev.class_dev); + struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev, + ibdev.dev); struct ethtool_drvinfo info; - struct net_device *lldev = dev->rdev.t3cdev_p->lldev; + struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev; - PDBG("%s class dev 0x%p\n", __func__, cdev); - rtnl_lock(); + PDBG("%s dev 0x%p\n", __func__, dev); lldev->ethtool_ops->get_drvinfo(lldev, &info); - rtnl_unlock(); return sprintf(buf, "%s\n", info.driver); } -static ssize_t show_board(struct class_device *cdev, char *buf) +static ssize_t show_board(struct device *dev, struct device_attribute *attr, + char *buf) { - struct iwch_dev *dev = container_of(cdev, struct iwch_dev, - ibdev.class_dev); - PDBG("%s class dev 0x%p\n", __func__, dev); - return sprintf(buf, "%x.%x\n", dev->rdev.rnic_info.pdev->vendor, - dev->rdev.rnic_info.pdev->device); + struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev, + ibdev.dev); + PDBG("%s dev 0x%p\n", __func__, dev); + return sprintf(buf, "%x.%x\n", iwch_dev->rdev.rnic_info.pdev->vendor, + iwch_dev->rdev.rnic_info.pdev->device); } -static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); -static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); -static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); -static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); +static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); +static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); +static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); +static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); -static struct class_device_attribute *iwch_class_attributes[] = { - &class_device_attr_hw_rev, - &class_device_attr_fw_ver, - &class_device_attr_hca_type, - &class_device_attr_board_id +static struct device_attribute *iwch_class_attributes[] = { + &dev_attr_hw_rev, + &dev_attr_fw_ver, + &dev_attr_hca_type, + &dev_attr_board_id }; int iwch_register_device(struct iwch_dev *dev) @@ -1189,8 +1188,8 @@ int iwch_register_device(struct iwch_dev *dev) goto bail1; for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i) { - ret = class_device_create_file(&dev->ibdev.class_dev, - iwch_class_attributes[i]); + ret = device_create_file(&dev->ibdev.dev, + iwch_class_attributes[i]); if (ret) { goto bail2; } @@ -1208,8 +1207,8 @@ void iwch_unregister_device(struct iwch_dev *dev) PDBG("%s iwch_dev %p\n", __func__, dev); for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i) - class_device_remove_file(&dev->ibdev.class_dev, - iwch_class_attributes[i]); + device_remove_file(&dev->ibdev.dev, + iwch_class_attributes[i]); ib_unregister_device(&dev->ibdev); return; } diff --git a/drivers/infiniband/hw/ipath/ipath_diag.c b/drivers/infiniband/hw/ipath/ipath_diag.c index 6d49d2f18a8..d4ce8b63e19 100644 --- a/drivers/infiniband/hw/ipath/ipath_diag.c +++ b/drivers/infiniband/hw/ipath/ipath_diag.c @@ -79,7 +79,7 @@ static const struct file_operations diagpkt_file_ops = { static atomic_t diagpkt_count = ATOMIC_INIT(0); static struct cdev *diagpkt_cdev; -static struct class_device *diagpkt_class_dev; +static struct device *diagpkt_dev; int ipath_diag_add(struct ipath_devdata *dd) { @@ -89,7 +89,7 @@ int ipath_diag_add(struct ipath_devdata *dd) if (atomic_inc_return(&diagpkt_count) == 1) { ret = ipath_cdev_init(IPATH_DIAGPKT_MINOR, "ipath_diagpkt", &diagpkt_file_ops, - &diagpkt_cdev, &diagpkt_class_dev); + &diagpkt_cdev, &diagpkt_dev); if (ret) { ipath_dev_err(dd, "Couldn't create ipath_diagpkt " @@ -102,7 +102,7 @@ int ipath_diag_add(struct ipath_devdata *dd) ret = ipath_cdev_init(IPATH_DIAG_MINOR_BASE + dd->ipath_unit, name, &diag_file_ops, &dd->diag_cdev, - &dd->diag_class_dev); + &dd->diag_dev); if (ret) ipath_dev_err(dd, "Couldn't create %s device: %d", name, ret); @@ -114,9 +114,9 @@ done: void ipath_diag_remove(struct ipath_devdata *dd) { if (atomic_dec_and_test(&diagpkt_count)) - ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_class_dev); + ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_dev); - ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_class_dev); + ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_dev); } /** diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c index 1e627aab18b..8b1752202e7 100644 --- a/drivers/infiniband/hw/ipath/ipath_file_ops.c +++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c @@ -2434,11 +2434,11 @@ static ssize_t ipath_writev(struct kiocb *iocb, const struct iovec *iov, static struct class *ipath_class; static int init_cdev(int minor, char *name, const struct file_operations *fops, - struct cdev **cdevp, struct class_device **class_devp) + struct cdev **cdevp, struct device **devp) { const dev_t dev = MKDEV(IPATH_MAJOR, minor); struct cdev *cdev = NULL; - struct class_device *class_dev = NULL; + struct device *device = NULL; int ret; cdev = cdev_alloc(); @@ -2462,12 +2462,12 @@ static int init_cdev(int minor, char *name, const struct file_operations *fops, goto err_cdev; } - class_dev = class_device_create(ipath_class, NULL, dev, NULL, name); + device = device_create(ipath_class, NULL, dev, name); - if (IS_ERR(class_dev)) { - ret = PTR_ERR(class_dev); + if (IS_ERR(device)) { + ret = PTR_ERR(device); printk(KERN_ERR IPATH_DRV_NAME ": Could not create " - "class_dev for minor %d, %s (err %d)\n", + "device for minor %d, %s (err %d)\n", minor, name, -ret); goto err_cdev; } @@ -2481,29 +2481,29 @@ err_cdev: done: if (ret >= 0) { *cdevp = cdev; - *class_devp = class_dev; + *devp = device; } else { *cdevp = NULL; - *class_devp = NULL; + *devp = NULL; } return ret; } int ipath_cdev_init(int minor, char *name, const struct file_operations *fops, - struct cdev **cdevp, struct class_device **class_devp) + struct cdev **cdevp, struct device **devp) { - return init_cdev(minor, name, fops, cdevp, class_devp); + return init_cdev(minor, name, fops, cdevp, devp); } static void cleanup_cdev(struct cdev **cdevp, - struct class_device **class_devp) + struct device **devp) { - struct class_device *class_dev = *class_devp; + struct device *dev = *devp; - if (class_dev) { - class_device_unregister(class_dev); - *class_devp = NULL; + if (dev) { + device_unregister(dev); + *devp = NULL; } if (*cdevp) { @@ -2513,13 +2513,13 @@ static void cleanup_cdev(struct cdev **cdevp, } void ipath_cdev_cleanup(struct cdev **cdevp, - struct class_device **class_devp) + struct device **devp) { - cleanup_cdev(cdevp, class_devp); + cleanup_cdev(cdevp, devp); } static struct cdev *wildcard_cdev; -static struct class_device *wildcard_class_dev; +static struct device *wildcard_dev; static const dev_t dev = MKDEV(IPATH_MAJOR, 0); @@ -2576,7 +2576,7 @@ int ipath_user_add(struct ipath_devdata *dd) goto bail; } ret = init_cdev(0, "ipath", &ipath_file_ops, &wildcard_cdev, - &wildcard_class_dev); + &wildcard_dev); if (ret < 0) { ipath_dev_err(dd, "Could not create wildcard " "minor: error %d\n", -ret); @@ -2589,7 +2589,7 @@ int ipath_user_add(struct ipath_devdata *dd) snprintf(name, sizeof(name), "ipath%d", dd->ipath_unit); ret = init_cdev(dd->ipath_unit + 1, name, &ipath_file_ops, - &dd->user_cdev, &dd->user_class_dev); + &dd->user_cdev, &dd->user_dev); if (ret < 0) ipath_dev_err(dd, "Could not create user minor %d, %s\n", dd->ipath_unit + 1, name); @@ -2604,13 +2604,13 @@ bail: void ipath_user_remove(struct ipath_devdata *dd) { - cleanup_cdev(&dd->user_cdev, &dd->user_class_dev); + cleanup_cdev(&dd->user_cdev, &dd->user_dev); if (atomic_dec_return(&user_count) == 0) { if (atomic_read(&user_setup) == 0) goto bail; - cleanup_cdev(&wildcard_cdev, &wildcard_class_dev); + cleanup_cdev(&wildcard_cdev, &wildcard_dev); user_cleanup(); atomic_set(&user_setup, 0); diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h b/drivers/infiniband/hw/ipath/ipath_kernel.h index 5863cbe9930..202337ae90d 100644 --- a/drivers/infiniband/hw/ipath/ipath_kernel.h +++ b/drivers/infiniband/hw/ipath/ipath_kernel.h @@ -466,8 +466,8 @@ struct ipath_devdata { struct pci_dev *pcidev; struct cdev *user_cdev; struct cdev *diag_cdev; - struct class_device *user_class_dev; - struct class_device *diag_class_dev; + struct device *user_dev; + struct device *diag_dev; /* timer used to prevent stats overflow, error throttling, etc. */ struct timer_list ipath_stats_timer; /* timer to verify interrupts work, and fallback if possible */ @@ -854,9 +854,9 @@ void ipath_clear_freeze(struct ipath_devdata *); struct file_operations; int ipath_cdev_init(int minor, char *name, const struct file_operations *fops, - struct cdev **cdevp, struct class_device **class_devp); + struct cdev **cdevp, struct device **devp); void ipath_cdev_cleanup(struct cdev **cdevp, - struct class_device **class_devp); + struct device **devp); int ipath_diag_add(struct ipath_devdata *); void ipath_diag_remove(struct ipath_devdata *); diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c index 320a6d018de..c38f9aa8be8 100644 --- a/drivers/infiniband/hw/ipath/ipath_verbs.c +++ b/drivers/infiniband/hw/ipath/ipath_verbs.c @@ -2172,18 +2172,20 @@ void ipath_unregister_ib_device(struct ipath_ibdev *dev) ib_dealloc_device(ibdev); } -static ssize_t show_rev(struct class_device *cdev, char *buf) +static ssize_t show_rev(struct device *device, struct device_attribute *attr, + char *buf) { struct ipath_ibdev *dev = - container_of(cdev, struct ipath_ibdev, ibdev.class_dev); + container_of(device, struct ipath_ibdev, ibdev.dev); return sprintf(buf, "%x\n", dev->dd->ipath_pcirev); } -static ssize_t show_hca(struct class_device *cdev, char *buf) +static ssize_t show_hca(struct device *device, struct device_attribute *attr, + char *buf) { struct ipath_ibdev *dev = - container_of(cdev, struct ipath_ibdev, ibdev.class_dev); + container_of(device, struct ipath_ibdev, ibdev.dev); int ret; ret = dev->dd->ipath_f_get_boardname(dev->dd, buf, 128); @@ -2196,10 +2198,11 @@ bail: return ret; } -static ssize_t show_stats(struct class_device *cdev, char *buf) +static ssize_t show_stats(struct device *device, struct device_attribute *attr, + char *buf) { struct ipath_ibdev *dev = - container_of(cdev, struct ipath_ibdev, ibdev.class_dev); + container_of(device, struct ipath_ibdev, ibdev.dev); int i; int len; @@ -2237,16 +2240,16 @@ static ssize_t show_stats(struct class_device *cdev, char *buf) return len; } -static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); -static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); -static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_hca, NULL); -static CLASS_DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL); +static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); +static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); +static DEVICE_ATTR(board_id, S_IRUGO, show_hca, NULL); +static DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL); -static struct class_device_attribute *ipath_class_attributes[] = { - &class_device_attr_hw_rev, - &class_device_attr_hca_type, - &class_device_attr_board_id, - &class_device_attr_stats +static struct device_attribute *ipath_class_attributes[] = { + &dev_attr_hw_rev, + &dev_attr_hca_type, + &dev_attr_board_id, + &dev_attr_stats }; static int ipath_verbs_register_sysfs(struct ib_device *dev) @@ -2255,8 +2258,8 @@ static int ipath_verbs_register_sysfs(struct ib_device *dev) int ret; for (i = 0; i < ARRAY_SIZE(ipath_class_attributes); ++i) - if (class_device_create_file(&dev->class_dev, - ipath_class_attributes[i])) { + if (device_create_file(&dev->dev, + ipath_class_attributes[i])) { ret = 1; goto bail; } diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index 136c76c7b4e..4d9b5ac4220 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c @@ -481,42 +481,51 @@ out: return err; } -static ssize_t show_hca(struct class_device *cdev, char *buf) +static ssize_t show_hca(struct device *device, struct device_attribute *attr, + char *buf) { - struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev); + struct mlx4_ib_dev *dev = + container_of(device, struct mlx4_ib_dev, ib_dev.dev); return sprintf(buf, "MT%d\n", dev->dev->pdev->device); } -static ssize_t show_fw_ver(struct class_device *cdev, char *buf) +static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr, + char *buf) { - struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev); + struct mlx4_ib_dev *dev = + container_of(device, struct mlx4_ib_dev, ib_dev.dev); return sprintf(buf, "%d.%d.%d\n", (int) (dev->dev->caps.fw_ver >> 32), (int) (dev->dev->caps.fw_ver >> 16) & 0xffff, (int) dev->dev->caps.fw_ver & 0xffff); } -static ssize_t show_rev(struct class_device *cdev, char *buf) +static ssize_t show_rev(struct device *device, struct device_attribute *attr, + char *buf) { - struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev); + struct mlx4_ib_dev *dev = + container_of(device, struct mlx4_ib_dev, ib_dev.dev); return sprintf(buf, "%x\n", dev->dev->rev_id); } -static ssize_t show_board(struct class_device *cdev, char *buf) +static ssize_t show_board(struct device *device, struct device_attribute *attr, + char *buf) { - struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev); - return sprintf(buf, "%.*s\n", MLX4_BOARD_ID_LEN, dev->dev->board_id); + struct mlx4_ib_dev *dev = + container_of(device, struct mlx4_ib_dev, ib_dev.dev); + return sprintf(buf, "%.*s\n", MLX4_BOARD_ID_LEN, + dev->dev->board_id); } -static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); -static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); -static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); -static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); +static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); +static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); +static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); +static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); -static struct class_device_attribute *mlx4_class_attributes[] = { - &class_device_attr_hw_rev, - &class_device_attr_fw_ver, - &class_device_attr_hca_type, - &class_device_attr_board_id +static struct device_attribute *mlx4_class_attributes[] = { + &dev_attr_hw_rev, + &dev_attr_fw_ver, + &dev_attr_hca_type, + &dev_attr_board_id }; static void *mlx4_ib_add(struct mlx4_dev *dev) @@ -640,8 +649,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev) goto err_reg; for (i = 0; i < ARRAY_SIZE(mlx4_class_attributes); ++i) { - if (class_device_create_file(&ibdev->ib_dev.class_dev, - mlx4_class_attributes[i])) + if (device_create_file(&ibdev->ib_dev.dev, + mlx4_class_attributes[i])) goto err_reg; } diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c index 81b257e18bb..696e1f30233 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/drivers/infiniband/hw/mthca/mthca_provider.c @@ -1170,23 +1170,29 @@ static int mthca_unmap_fmr(struct list_head *fmr_list) return 0; } -static ssize_t show_rev(struct class_device *cdev, char *buf) +static ssize_t show_rev(struct device *device, struct device_attribute *attr, + char *buf) { - struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev); + struct mthca_dev *dev = + container_of(device, struct mthca_dev, ib_dev.dev); return sprintf(buf, "%x\n", dev->rev_id); } -static ssize_t show_fw_ver(struct class_device *cdev, char *buf) +static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr, + char *buf) { - struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev); + struct mthca_dev *dev = + container_of(device, struct mthca_dev, ib_dev.dev); return sprintf(buf, "%d.%d.%d\n", (int) (dev->fw_ver >> 32), (int) (dev->fw_ver >> 16) & 0xffff, (int) dev->fw_ver & 0xffff); } -static ssize_t show_hca(struct class_device *cdev, char *buf) +static ssize_t show_hca(struct device *device, struct device_attribute *attr, + char *buf) { - struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev); + struct mthca_dev *dev = + container_of(device, struct mthca_dev, ib_dev.dev); switch (dev->pdev->device) { case PCI_DEVICE_ID_MELLANOX_TAVOR: return sprintf(buf, "MT23108\n"); @@ -1202,22 +1208,24 @@ static ssize_t show_hca(struct class_device *cdev, char *buf) } } -static ssize_t show_board(struct class_device *cdev, char *buf) +static ssize_t show_board(struct device *device, struct device_attribute *attr, + char *buf) { - struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev); + struct mthca_dev *dev = + container_of(device, struct mthca_dev, ib_dev.dev); return sprintf(buf, "%.*s\n", MTHCA_BOARD_ID_LEN, dev->board_id); } -static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); -static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); -static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); -static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); +static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); +static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); +static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); +static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); -static struct class_device_attribute *mthca_class_attributes[] = { - &class_device_attr_hw_rev, - &class_device_attr_fw_ver, - &class_device_attr_hca_type, - &class_device_attr_board_id +static struct device_attribute *mthca_dev_attributes[] = { + &dev_attr_hw_rev, + &dev_attr_fw_ver, + &dev_attr_hca_type, + &dev_attr_board_id }; static int mthca_init_node_data(struct mthca_dev *dev) @@ -1379,9 +1387,9 @@ int mthca_register_device(struct mthca_dev *dev) if (ret) return ret; - for (i = 0; i < ARRAY_SIZE(mthca_class_attributes); ++i) { - ret = class_device_create_file(&dev->ib_dev.class_dev, - mthca_class_attributes[i]); + for (i = 0; i < ARRAY_SIZE(mthca_dev_attributes); ++i) { + ret = device_create_file(&dev->ib_dev.dev, + mthca_dev_attributes[i]); if (ret) { ib_unregister_device(&dev->ib_dev); return ret; diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c index 7c27420c224..f9a5d439089 100644 --- a/drivers/infiniband/hw/nes/nes_verbs.c +++ b/drivers/infiniband/hw/nes/nes_verbs.c @@ -2800,10 +2800,11 @@ static int nes_dereg_mr(struct ib_mr *ib_mr) /** * show_rev */ -static ssize_t show_rev(struct class_device *cdev, char *buf) +static ssize_t show_rev(struct device *dev, struct device_attribute *attr, + char *buf) { struct nes_ib_device *nesibdev = - container_of(cdev, struct nes_ib_device, ibdev.class_dev); + container_of(dev, struct nes_ib_device, ibdev.dev); struct nes_vnic *nesvnic = nesibdev->nesvnic; nes_debug(NES_DBG_INIT, "\n"); @@ -2814,10 +2815,11 @@ static ssize_t show_rev(struct class_device *cdev, char *buf) /** * show_fw_ver */ -static ssize_t show_fw_ver(struct class_device *cdev, char *buf) +static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, + char *buf) { struct nes_ib_device *nesibdev = - container_of(cdev, struct nes_ib_device, ibdev.class_dev); + container_of(dev, struct nes_ib_device, ibdev.dev); struct nes_vnic *nesvnic = nesibdev->nesvnic; nes_debug(NES_DBG_INIT, "\n"); @@ -2831,7 +2833,8 @@ static ssize_t show_fw_ver(struct class_device *cdev, char *buf) /** * show_hca */ -static ssize_t show_hca(struct class_device *cdev, char *buf) +static ssize_t show_hca(struct device *dev, struct device_attribute *attr, + char *buf) { nes_debug(NES_DBG_INIT, "\n"); return sprintf(buf, "NES020\n"); @@ -2841,23 +2844,24 @@ static ssize_t show_hca(struct class_device *cdev, char *buf) /** * show_board */ -static ssize_t show_board(struct class_device *cdev, char *buf) +static ssize_t show_board(struct device *dev, struct device_attribute *attr, + char *buf) { nes_debug(NES_DBG_INIT, "\n"); return sprintf(buf, "%.*s\n", 32, "NES020 Board ID"); } -static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); -static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); -static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); -static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); +static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); +static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); +static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); +static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); -static struct class_device_attribute *nes_class_attributes[] = { - &class_device_attr_hw_rev, - &class_device_attr_fw_ver, - &class_device_attr_hca_type, - &class_device_attr_board_id +static struct device_attribute *nes_dev_attributes[] = { + &dev_attr_hw_rev, + &dev_attr_fw_ver, + &dev_attr_hca_type, + &dev_attr_board_id }; @@ -3782,7 +3786,7 @@ struct nes_ib_device *nes_init_ofa_device(struct net_device *netdev) nesibdev->ibdev.phys_port_cnt = 1; nesibdev->ibdev.num_comp_vectors = 1; nesibdev->ibdev.dma_device = &nesdev->pcidev->dev; - nesibdev->ibdev.class_dev.dev = &nesdev->pcidev->dev; + nesibdev->ibdev.dev.parent = &nesdev->pcidev->dev; nesibdev->ibdev.query_device = nes_query_device; nesibdev->ibdev.query_port = nes_query_port; nesibdev->ibdev.modify_port = nes_modify_port; @@ -3877,13 +3881,13 @@ int nes_register_ofa_device(struct nes_ib_device *nesibdev) nesibdev->max_qp = (nesadapter->max_qp-NES_FIRST_QPN) / nesadapter->port_count; nesibdev->max_pd = nesadapter->max_pd / nesadapter->port_count; - for (i = 0; i < ARRAY_SIZE(nes_class_attributes); ++i) { - ret = class_device_create_file(&nesibdev->ibdev.class_dev, nes_class_attributes[i]); + for (i = 0; i < ARRAY_SIZE(nes_dev_attributes); ++i) { + ret = device_create_file(&nesibdev->ibdev.dev, nes_dev_attributes[i]); if (ret) { while (i > 0) { i--; - class_device_remove_file(&nesibdev->ibdev.class_dev, - nes_class_attributes[i]); + device_remove_file(&nesibdev->ibdev.dev, + nes_dev_attributes[i]); } ib_unregister_device(&nesibdev->ibdev); return ret; @@ -3904,8 +3908,8 @@ static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev) struct nes_vnic *nesvnic = nesibdev->nesvnic; int i; - for (i = 0; i < ARRAY_SIZE(nes_class_attributes); ++i) { - class_device_remove_file(&nesibdev->ibdev.class_dev, nes_class_attributes[i]); + for (i = 0; i < ARRAY_SIZE(nes_dev_attributes); ++i) { + device_remove_file(&nesibdev->ibdev.dev, nes_dev_attributes[i]); } if (nesvnic->of_device_registered) { diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 95bf4bac44c..2dcbecce3f6 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1051,7 +1051,7 @@ struct ib_device { struct ib_dma_mapping_ops *dma_ops; struct module *owner; - struct class_device class_dev; + struct device dev; struct kobject *ports_parent; struct list_head port_list; -- cgit v1.2.3-70-g09d2