Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband:
mlx4: Update/add Mellanox Technologies copyright lines to mlx4 driver files
mlx4_core: Add VLAN tag field to WQE control segment struct
RDMA/nes: CM connection setup/teardown rework
IPoIB: Correct help text for INFINIBAND_IPOIB_DEBUG
IPoIB/cm: Connected mode is no longer EXPERIMENTAL
RDMA/ucm: BKL is not needed for ib_ucm_open()
RDMA/ucma: BKL is not needed for ucma_open()

+1221 -966
+8 -2
drivers/infiniband/core/ucm.c
··· 43 43 #include <linux/cdev.h> 44 44 #include <linux/idr.h> 45 45 #include <linux/mutex.h> 46 - #include <linux/smp_lock.h> 47 46 48 47 #include <asm/uaccess.h> 49 48 ··· 1153 1154 return mask; 1154 1155 } 1155 1156 1157 + /* 1158 + * ib_ucm_open() does not need the BKL: 1159 + * 1160 + * - no global state is referred to; 1161 + * - there is no ioctl method to race against; 1162 + * - no further module initialization is required for open to work 1163 + * after the device is registered. 1164 + */ 1156 1165 static int ib_ucm_open(struct inode *inode, struct file *filp) 1157 1166 { 1158 1167 struct ib_ucm_file *file; 1159 1168 1160 - cycle_kernel_lock(); 1161 1169 file = kmalloc(sizeof(*file), GFP_KERNEL); 1162 1170 if (!file) 1163 1171 return -ENOMEM;
+8 -3
drivers/infiniband/core/ucma.c
··· 38 38 #include <linux/in.h> 39 39 #include <linux/in6.h> 40 40 #include <linux/miscdevice.h> 41 - #include <linux/smp_lock.h> 42 41 43 42 #include <rdma/rdma_user_cm.h> 44 43 #include <rdma/ib_marshall.h> ··· 1148 1149 return mask; 1149 1150 } 1150 1151 1152 + /* 1153 + * ucma_open() does not need the BKL: 1154 + * 1155 + * - no global state is referred to; 1156 + * - there is no ioctl method to race against; 1157 + * - no further module initialization is required for open to work 1158 + * after the device is registered. 1159 + */ 1151 1160 static int ucma_open(struct inode *inode, struct file *filp) 1152 1161 { 1153 1162 struct ucma_file *file; ··· 1164 1157 if (!file) 1165 1158 return -ENOMEM; 1166 1159 1167 - lock_kernel(); 1168 1160 INIT_LIST_HEAD(&file->event_list); 1169 1161 INIT_LIST_HEAD(&file->ctx_list); 1170 1162 init_waitqueue_head(&file->poll_wait); ··· 1171 1165 1172 1166 filp->private_data = file; 1173 1167 file->filp = filp; 1174 - unlock_kernel(); 1175 1168 return 0; 1176 1169 } 1177 1170
+1
drivers/infiniband/hw/mlx4/cq.c
··· 1 1 /* 2 2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. 3 + * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. 3 4 * 4 5 * This software is available to you under a choice of one of two 5 6 * licenses. You may choose to be licensed under the terms of the GNU
+1
drivers/infiniband/hw/mlx4/main.c
··· 1 1 /* 2 2 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. 3 + * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. 3 4 * 4 5 * This software is available to you under a choice of one of two 5 6 * licenses. You may choose to be licensed under the terms of the GNU
+1
drivers/infiniband/hw/mlx4/mlx4_ib.h
··· 1 1 /* 2 2 * Copyright (c) 2006, 2007 Cisco Systems. All rights reserved. 3 + * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. 3 4 * 4 5 * This software is available to you under a choice of one of two 5 6 * licenses. You may choose to be licensed under the terms of the GNU
+1
drivers/infiniband/hw/mlx4/mr.c
··· 1 1 /* 2 2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. 3 + * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. 3 4 * 4 5 * This software is available to you under a choice of one of two 5 6 * licenses. You may choose to be licensed under the terms of the GNU
+1
drivers/infiniband/hw/mlx4/qp.c
··· 1 1 /* 2 2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. 3 + * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. 3 4 * 4 5 * This software is available to you under a choice of one of two 5 6 * licenses. You may choose to be licensed under the terms of the GNU
+1
drivers/infiniband/hw/mlx4/srq.c
··· 1 1 /* 2 2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. 3 + * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. 3 4 * 4 5 * This software is available to you under a choice of one of two 5 6 * licenses. You may choose to be licensed under the terms of the GNU
+1
drivers/infiniband/hw/mlx4/user.h
··· 1 1 /* 2 2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. 3 + * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. 3 4 * 4 5 * This software is available to you under a choice of one of two 5 6 * licenses. You may choose to be licensed under the terms of the GNU
+1 -3
drivers/infiniband/hw/nes/nes.c
··· 276 276 } 277 277 nes_free_resource(nesadapter, nesadapter->allocated_qps, nesqp->hwqp.qp_id); 278 278 279 + nesadapter->qp_table[nesqp->hwqp.qp_id-NES_FIRST_QPN] = NULL; 279 280 kfree(nesqp->allocated_buffer); 280 281 281 282 } ··· 290 289 struct nes_qp *nesqp; 291 290 struct nes_vnic *nesvnic = to_nesvnic(ibqp->device); 292 291 struct nes_device *nesdev = nesvnic->nesdev; 293 - struct nes_adapter *nesadapter = nesdev->nesadapter; 294 292 struct nes_hw_cqp_wqe *cqp_wqe; 295 293 struct nes_cqp_request *cqp_request; 296 294 u32 opcode; ··· 303 303 } 304 304 305 305 if (atomic_dec_and_test(&nesqp->refcount)) { 306 - nesadapter->qp_table[nesqp->hwqp.qp_id-NES_FIRST_QPN] = NULL; 307 - 308 306 /* Destroy the QP */ 309 307 cqp_request = nes_get_cqp_request(nesdev); 310 308 if (cqp_request == NULL) {
+1145 -909
drivers/infiniband/hw/nes/nes_cm.c
··· 74 74 atomic_t cm_accel_dropped_pkts; 75 75 atomic_t cm_resets_recvd; 76 76 77 - static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *); 77 + static inline int mini_cm_accelerated(struct nes_cm_core *, 78 + struct nes_cm_node *); 78 79 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, 79 - struct nes_vnic *, struct nes_cm_info *); 80 - static int add_ref_cm_node(struct nes_cm_node *); 81 - static int rem_ref_cm_node(struct nes_cm_core *, struct nes_cm_node *); 80 + struct nes_vnic *, struct nes_cm_info *); 82 81 static int mini_cm_del_listen(struct nes_cm_core *, struct nes_cm_listener *); 83 - static struct sk_buff *form_cm_frame(struct sk_buff *, struct nes_cm_node *, 84 - void *, u32, void *, u32, u8); 85 - static struct sk_buff *get_free_pkt(struct nes_cm_node *cm_node); 86 - 87 82 static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *, 88 - struct nes_vnic *, 89 - struct ietf_mpa_frame *, 90 - struct nes_cm_info *); 91 - static int mini_cm_accept(struct nes_cm_core *, struct ietf_mpa_frame *, 92 - struct nes_cm_node *); 93 - static int mini_cm_reject(struct nes_cm_core *, struct ietf_mpa_frame *, 94 - struct nes_cm_node *); 83 + struct nes_vnic *, u16, void *, struct nes_cm_info *); 95 84 static int mini_cm_close(struct nes_cm_core *, struct nes_cm_node *); 96 - static int mini_cm_recv_pkt(struct nes_cm_core *, struct nes_vnic *, 97 - struct sk_buff *); 85 + static int mini_cm_accept(struct nes_cm_core *, struct ietf_mpa_frame *, 86 + struct nes_cm_node *); 87 + static int mini_cm_reject(struct nes_cm_core *, struct ietf_mpa_frame *, 88 + struct nes_cm_node *); 89 + static void mini_cm_recv_pkt(struct nes_cm_core *, struct nes_vnic *, 90 + struct sk_buff *); 98 91 static int mini_cm_dealloc_core(struct nes_cm_core *); 99 92 static int mini_cm_get(struct nes_cm_core *); 100 93 static int mini_cm_set(struct nes_cm_core *, u32, u32); 94 + 95 + static struct sk_buff *form_cm_frame(struct sk_buff *, struct nes_cm_node *, 96 + void *, u32, void *, u32, u8); 97 + static struct sk_buff *get_free_pkt(struct nes_cm_node *cm_node); 98 + static int add_ref_cm_node(struct nes_cm_node *); 99 + static int rem_ref_cm_node(struct nes_cm_core *, struct nes_cm_node *); 100 + 101 101 static int nes_cm_disconn_true(struct nes_qp *); 102 102 static int nes_cm_post_event(struct nes_cm_event *event); 103 103 static int nes_disconnect(struct nes_qp *nesqp, int abrupt); 104 104 static void nes_disconnect_worker(struct work_struct *work); 105 - static int send_ack(struct nes_cm_node *cm_node); 105 + 106 + static int send_mpa_request(struct nes_cm_node *, struct sk_buff *); 107 + static int send_syn(struct nes_cm_node *, u32, struct sk_buff *); 108 + static int send_reset(struct nes_cm_node *, struct sk_buff *); 109 + static int send_ack(struct nes_cm_node *cm_node, struct sk_buff *skb); 106 110 static int send_fin(struct nes_cm_node *cm_node, struct sk_buff *skb); 111 + static void process_packet(struct nes_cm_node *, struct sk_buff *, 112 + struct nes_cm_core *); 113 + 114 + static void active_open_err(struct nes_cm_node *, struct sk_buff *, int); 115 + static void passive_open_err(struct nes_cm_node *, struct sk_buff *, int); 116 + static void cleanup_retrans_entry(struct nes_cm_node *); 117 + static void handle_rcv_mpa(struct nes_cm_node *, struct sk_buff *, 118 + enum nes_cm_event_type); 119 + static void free_retrans_entry(struct nes_cm_node *cm_node); 120 + static int handle_tcp_options(struct nes_cm_node *cm_node, struct tcphdr *tcph, 121 + struct sk_buff *skb, int optionsize, int passive); 122 + 123 + /* CM event handler functions */ 124 + static void cm_event_connected(struct nes_cm_event *); 125 + static void cm_event_connect_error(struct nes_cm_event *); 126 + static void cm_event_reset(struct nes_cm_event *); 127 + static void cm_event_mpa_req(struct nes_cm_event *); 128 + 129 + static void print_core(struct nes_cm_core *core); 107 130 108 131 /* External CM API Interface */ 109 132 /* instance of function pointers for client API */ ··· 181 158 event->cm_info.loc_port = cm_node->loc_port; 182 159 event->cm_info.cm_id = cm_node->cm_id; 183 160 184 - nes_debug(NES_DBG_CM, "Created event=%p, type=%u, dst_addr=%08x[%x]," 185 - " src_addr=%08x[%x]\n", 186 - event, type, 187 - event->cm_info.loc_addr, event->cm_info.loc_port, 188 - event->cm_info.rem_addr, event->cm_info.rem_port); 161 + nes_debug(NES_DBG_CM, "cm_node=%p Created event=%p, type=%u, " 162 + "dst_addr=%08x[%x], src_addr=%08x[%x]\n", 163 + cm_node, event, type, event->cm_info.loc_addr, 164 + event->cm_info.loc_port, event->cm_info.rem_addr, 165 + event->cm_info.rem_port); 189 166 190 167 nes_cm_post_event(event); 191 168 return event; ··· 195 172 /** 196 173 * send_mpa_request 197 174 */ 198 - static int send_mpa_request(struct nes_cm_node *cm_node) 175 + static int send_mpa_request(struct nes_cm_node *cm_node, struct sk_buff *skb) 199 176 { 200 - struct sk_buff *skb; 201 177 int ret; 202 - 203 - skb = get_free_pkt(cm_node); 204 178 if (!skb) { 205 - nes_debug(NES_DBG_CM, "Failed to get a Free pkt\n"); 179 + nes_debug(NES_DBG_CM, "skb set to NULL\n"); 206 180 return -1; 207 181 } 208 182 ··· 208 188 cm_node->mpa_frame_size, SET_ACK); 209 189 210 190 ret = schedule_nes_timer(cm_node, skb, NES_TIMER_TYPE_SEND, 1, 0); 211 - if (ret < 0) { 191 + if (ret < 0) 212 192 return ret; 213 - } 214 193 215 194 return 0; 216 195 } ··· 248 229 249 230 250 231 /** 251 - * handle_exception_pkt - process an exception packet. 252 - * We have been in a TSA state, and we have now received SW 253 - * TCP/IP traffic should be a FIN request or IP pkt with options 254 - */ 255 - static int handle_exception_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb) 256 - { 257 - int ret = 0; 258 - struct tcphdr *tcph = tcp_hdr(skb); 259 - 260 - /* first check to see if this a FIN pkt */ 261 - if (tcph->fin) { 262 - /* we need to ACK the FIN request */ 263 - send_ack(cm_node); 264 - 265 - /* check which side we are (client/server) and set next state accordingly */ 266 - if (cm_node->tcp_cntxt.client) 267 - cm_node->state = NES_CM_STATE_CLOSING; 268 - else { 269 - /* we are the server side */ 270 - cm_node->state = NES_CM_STATE_CLOSE_WAIT; 271 - /* since this is a self contained CM we don't wait for */ 272 - /* an APP to close us, just send final FIN immediately */ 273 - ret = send_fin(cm_node, NULL); 274 - cm_node->state = NES_CM_STATE_LAST_ACK; 275 - } 276 - } else { 277 - ret = -EINVAL; 278 - } 279 - 280 - return ret; 281 - } 282 - 283 - 284 - /** 285 232 * form_cm_frame - get a free packet and build empty frame Use 286 233 * node info to build. 287 234 */ 288 - static struct sk_buff *form_cm_frame(struct sk_buff *skb, struct nes_cm_node *cm_node, 289 - void *options, u32 optionsize, void *data, 290 - u32 datasize, u8 flags) 235 + static struct sk_buff *form_cm_frame(struct sk_buff *skb, 236 + struct nes_cm_node *cm_node, void *options, u32 optionsize, 237 + void *data, u32 datasize, u8 flags) 291 238 { 292 239 struct tcphdr *tcph; 293 240 struct iphdr *iph; ··· 317 332 cm_node->tcp_cntxt.loc_seq_num++; 318 333 tcph->syn = 1; 319 334 } else 320 - cm_node->tcp_cntxt.loc_seq_num += datasize; /* data (no headers) */ 335 + cm_node->tcp_cntxt.loc_seq_num += datasize; 321 336 322 - if (flags & SET_FIN) 337 + if (flags & SET_FIN) { 338 + cm_node->tcp_cntxt.loc_seq_num++; 323 339 tcph->fin = 1; 340 + } 324 341 325 342 if (flags & SET_RST) 326 343 tcph->rst = 1; ··· 376 389 int close_when_complete) 377 390 { 378 391 unsigned long flags; 379 - struct nes_cm_core *cm_core; 392 + struct nes_cm_core *cm_core = cm_node->cm_core; 380 393 struct nes_timer_entry *new_send; 381 394 int ret = 0; 382 395 u32 was_timer_set; ··· 398 411 new_send->close_when_complete = close_when_complete; 399 412 400 413 if (type == NES_TIMER_TYPE_CLOSE) { 401 - new_send->timetosend += (HZ/2); /* TODO: decide on the correct value here */ 414 + new_send->timetosend += (HZ/10); 402 415 spin_lock_irqsave(&cm_node->recv_list_lock, flags); 403 416 list_add_tail(&new_send->list, &cm_node->recv_list); 404 417 spin_unlock_irqrestore(&cm_node->recv_list_lock, flags); ··· 407 420 if (type == NES_TIMER_TYPE_SEND) { 408 421 new_send->seq_num = ntohl(tcp_hdr(skb)->seq); 409 422 atomic_inc(&new_send->skb->users); 423 + spin_lock_irqsave(&cm_node->retrans_list_lock, flags); 424 + cm_node->send_entry = new_send; 425 + add_ref_cm_node(cm_node); 426 + spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags); 427 + new_send->timetosend = jiffies + NES_RETRY_TIMEOUT; 410 428 411 429 ret = nes_nic_cm_xmit(new_send->skb, cm_node->netdev); 412 430 if (ret != NETDEV_TX_OK) { 413 - nes_debug(NES_DBG_CM, "Error sending packet %p (jiffies = %lu)\n", 414 - new_send, jiffies); 431 + nes_debug(NES_DBG_CM, "Error sending packet %p " 432 + "(jiffies = %lu)\n", new_send, jiffies); 415 433 atomic_dec(&new_send->skb->users); 416 434 new_send->timetosend = jiffies; 417 435 } else { 418 436 cm_packets_sent++; 419 437 if (!send_retrans) { 438 + cleanup_retrans_entry(cm_node); 420 439 if (close_when_complete) 421 - rem_ref_cm_node(cm_node->cm_core, cm_node); 422 - dev_kfree_skb_any(new_send->skb); 423 - kfree(new_send); 440 + rem_ref_cm_node(cm_core, cm_node); 424 441 return ret; 425 442 } 426 - new_send->timetosend = jiffies + NES_RETRY_TIMEOUT; 427 443 } 428 - spin_lock_irqsave(&cm_node->retrans_list_lock, flags); 429 - list_add_tail(&new_send->list, &cm_node->retrans_list); 430 - spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags); 431 444 } 432 - if (type == NES_TIMER_TYPE_RECV) { 433 - new_send->seq_num = ntohl(tcp_hdr(skb)->seq); 434 - new_send->timetosend = jiffies; 435 - spin_lock_irqsave(&cm_node->recv_list_lock, flags); 436 - list_add_tail(&new_send->list, &cm_node->recv_list); 437 - spin_unlock_irqrestore(&cm_node->recv_list_lock, flags); 438 - } 439 - cm_core = cm_node->cm_core; 440 445 441 446 was_timer_set = timer_pending(&cm_core->tcp_timer); 442 447 ··· 455 476 struct list_head *list_node, *list_node_temp; 456 477 struct nes_cm_core *cm_core = g_cm_core; 457 478 struct nes_qp *nesqp; 458 - struct sk_buff *skb; 459 479 u32 settimer = 0; 460 480 int ret = NETDEV_TX_OK; 461 - int node_done; 481 + enum nes_cm_node_state last_state; 462 482 463 483 spin_lock_irqsave(&cm_core->ht_lock, flags); 464 484 465 - list_for_each_safe(list_node, list_core_temp, &cm_core->connected_nodes) { 485 + list_for_each_safe(list_node, list_core_temp, 486 + &cm_core->connected_nodes) { 466 487 cm_node = container_of(list_node, struct nes_cm_node, list); 467 488 add_ref_cm_node(cm_node); 468 489 spin_unlock_irqrestore(&cm_core->ht_lock, flags); 469 490 spin_lock_irqsave(&cm_node->recv_list_lock, flags); 470 - list_for_each_safe(list_core, list_node_temp, &cm_node->recv_list) { 471 - recv_entry = container_of(list_core, struct nes_timer_entry, list); 472 - if ((time_after(recv_entry->timetosend, jiffies)) && 473 - (recv_entry->type == NES_TIMER_TYPE_CLOSE)) { 474 - if (nexttimeout > recv_entry->timetosend || !settimer) { 491 + list_for_each_safe(list_core, list_node_temp, 492 + &cm_node->recv_list) { 493 + recv_entry = container_of(list_core, 494 + struct nes_timer_entry, list); 495 + if (!recv_entry) 496 + break; 497 + if (time_after(recv_entry->timetosend, jiffies)) { 498 + if (nexttimeout > recv_entry->timetosend || 499 + !settimer) { 475 500 nexttimeout = recv_entry->timetosend; 476 501 settimer = 1; 477 502 } ··· 484 501 list_del(&recv_entry->list); 485 502 cm_id = cm_node->cm_id; 486 503 spin_unlock_irqrestore(&cm_node->recv_list_lock, flags); 487 - if (recv_entry->type == NES_TIMER_TYPE_CLOSE) { 488 - nesqp = (struct nes_qp *)recv_entry->skb; 489 - spin_lock_irqsave(&nesqp->lock, qplockflags); 490 - if (nesqp->cm_id) { 491 - nes_debug(NES_DBG_CM, "QP%u: cm_id = %p, refcount = %d: " 492 - "****** HIT A NES_TIMER_TYPE_CLOSE" 493 - " with something to do!!! ******\n", 494 - nesqp->hwqp.qp_id, cm_id, 495 - atomic_read(&nesqp->refcount)); 496 - nesqp->hw_tcp_state = NES_AEQE_TCP_STATE_CLOSED; 497 - nesqp->last_aeq = NES_AEQE_AEID_RESET_SENT; 498 - nesqp->ibqp_state = IB_QPS_ERR; 499 - spin_unlock_irqrestore(&nesqp->lock, qplockflags); 500 - nes_cm_disconn(nesqp); 501 - } else { 502 - spin_unlock_irqrestore(&nesqp->lock, qplockflags); 503 - nes_debug(NES_DBG_CM, "QP%u: cm_id = %p, refcount = %d:" 504 - " ****** HIT A NES_TIMER_TYPE_CLOSE" 505 - " with nothing to do!!! ******\n", 506 - nesqp->hwqp.qp_id, cm_id, 507 - atomic_read(&nesqp->refcount)); 508 - nes_rem_ref(&nesqp->ibqp); 509 - } 510 - if (cm_id) 511 - cm_id->rem_ref(cm_id); 504 + nesqp = (struct nes_qp *)recv_entry->skb; 505 + spin_lock_irqsave(&nesqp->lock, qplockflags); 506 + if (nesqp->cm_id) { 507 + nes_debug(NES_DBG_CM, "QP%u: cm_id = %p, " 508 + "refcount = %d: HIT A " 509 + "NES_TIMER_TYPE_CLOSE with something " 510 + "to do!!!\n", nesqp->hwqp.qp_id, cm_id, 511 + atomic_read(&nesqp->refcount)); 512 + nesqp->hw_tcp_state = NES_AEQE_TCP_STATE_CLOSED; 513 + nesqp->last_aeq = NES_AEQE_AEID_RESET_SENT; 514 + nesqp->ibqp_state = IB_QPS_ERR; 515 + spin_unlock_irqrestore(&nesqp->lock, 516 + qplockflags); 517 + nes_cm_disconn(nesqp); 518 + } else { 519 + spin_unlock_irqrestore(&nesqp->lock, 520 + qplockflags); 521 + nes_debug(NES_DBG_CM, "QP%u: cm_id = %p, " 522 + "refcount = %d: HIT A " 523 + "NES_TIMER_TYPE_CLOSE with nothing " 524 + "to do!!!\n", nesqp->hwqp.qp_id, cm_id, 525 + atomic_read(&nesqp->refcount)); 512 526 } 527 + if (cm_id) 528 + cm_id->rem_ref(cm_id); 529 + 513 530 kfree(recv_entry); 514 531 spin_lock_irqsave(&cm_node->recv_list_lock, flags); 515 532 } 516 533 spin_unlock_irqrestore(&cm_node->recv_list_lock, flags); 517 534 518 535 spin_lock_irqsave(&cm_node->retrans_list_lock, flags); 519 - node_done = 0; 520 - list_for_each_safe(list_core, list_node_temp, &cm_node->retrans_list) { 521 - if (node_done) { 522 - break; 523 - } 524 - send_entry = container_of(list_core, struct nes_timer_entry, list); 536 + do { 537 + send_entry = cm_node->send_entry; 538 + if (!send_entry) 539 + continue; 525 540 if (time_after(send_entry->timetosend, jiffies)) { 526 541 if (cm_node->state != NES_CM_STATE_TSA) { 527 - if ((nexttimeout > send_entry->timetosend) || !settimer) { 528 - nexttimeout = send_entry->timetosend; 542 + if ((nexttimeout > 543 + send_entry->timetosend) || 544 + !settimer) { 545 + nexttimeout = 546 + send_entry->timetosend; 529 547 settimer = 1; 548 + continue; 530 549 } 531 - node_done = 1; 532 - continue; 533 550 } else { 534 - list_del(&send_entry->list); 535 - skb = send_entry->skb; 536 - spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags); 537 - dev_kfree_skb_any(skb); 538 - kfree(send_entry); 539 - spin_lock_irqsave(&cm_node->retrans_list_lock, flags); 551 + free_retrans_entry(cm_node); 540 552 continue; 541 553 } 542 554 } 543 - if (send_entry->type == NES_TIMER_NODE_CLEANUP) { 544 - list_del(&send_entry->list); 545 - spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags); 546 - kfree(send_entry); 547 - spin_lock_irqsave(&cm_node->retrans_list_lock, flags); 548 - continue; 549 - } 550 - if ((send_entry->seq_num < cm_node->tcp_cntxt.rem_ack_num) || 551 - (cm_node->state == NES_CM_STATE_TSA) || 552 - (cm_node->state == NES_CM_STATE_CLOSED)) { 553 - skb = send_entry->skb; 554 - list_del(&send_entry->list); 555 - spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags); 556 - kfree(send_entry); 557 - dev_kfree_skb_any(skb); 558 - spin_lock_irqsave(&cm_node->retrans_list_lock, flags); 555 + 556 + if ((cm_node->state == NES_CM_STATE_TSA) || 557 + (cm_node->state == NES_CM_STATE_CLOSED)) { 558 + free_retrans_entry(cm_node); 559 559 continue; 560 560 } 561 561 562 - if (!send_entry->retranscount || !send_entry->retrycount) { 562 + if (!send_entry->retranscount || 563 + !send_entry->retrycount) { 563 564 cm_packets_dropped++; 564 - skb = send_entry->skb; 565 - list_del(&send_entry->list); 566 - spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags); 567 - dev_kfree_skb_any(skb); 568 - kfree(send_entry); 569 - if (cm_node->state == NES_CM_STATE_SYN_RCVD) { 570 - /* this node never even generated an indication up to the cm */ 565 + last_state = cm_node->state; 566 + cm_node->state = NES_CM_STATE_CLOSED; 567 + free_retrans_entry(cm_node); 568 + spin_unlock_irqrestore( 569 + &cm_node->retrans_list_lock, flags); 570 + if (last_state == NES_CM_STATE_SYN_RCVD) 571 571 rem_ref_cm_node(cm_core, cm_node); 572 - } else { 573 - cm_node->state = NES_CM_STATE_CLOSED; 574 - create_event(cm_node, NES_CM_EVENT_ABORTED); 575 - } 576 - spin_lock_irqsave(&cm_node->retrans_list_lock, flags); 572 + else 573 + create_event(cm_node, 574 + NES_CM_EVENT_ABORTED); 575 + spin_lock_irqsave(&cm_node->retrans_list_lock, 576 + flags); 577 577 continue; 578 578 } 579 - /* this seems like the correct place, but leave send entry unprotected */ 580 - /* spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags); */ 581 579 atomic_inc(&send_entry->skb->users); 582 580 cm_packets_retrans++; 583 - nes_debug(NES_DBG_CM, "Retransmitting send_entry %p for node %p," 584 - " jiffies = %lu, time to send = %lu, retranscount = %u, " 585 - "send_entry->seq_num = 0x%08X, cm_node->tcp_cntxt.rem_ack_num = 0x%08X\n", 586 - send_entry, cm_node, jiffies, send_entry->timetosend, send_entry->retranscount, 587 - send_entry->seq_num, cm_node->tcp_cntxt.rem_ack_num); 581 + nes_debug(NES_DBG_CM, "Retransmitting send_entry %p " 582 + "for node %p, jiffies = %lu, time to send = " 583 + "%lu, retranscount = %u, send_entry->seq_num = " 584 + "0x%08X, cm_node->tcp_cntxt.rem_ack_num = " 585 + "0x%08X\n", send_entry, cm_node, jiffies, 586 + send_entry->timetosend, 587 + send_entry->retranscount, 588 + send_entry->seq_num, 589 + cm_node->tcp_cntxt.rem_ack_num); 588 590 589 - spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags); 591 + spin_unlock_irqrestore(&cm_node->retrans_list_lock, 592 + flags); 590 593 ret = nes_nic_cm_xmit(send_entry->skb, cm_node->netdev); 594 + spin_lock_irqsave(&cm_node->retrans_list_lock, flags); 591 595 if (ret != NETDEV_TX_OK) { 596 + nes_debug(NES_DBG_CM, "rexmit failed for " 597 + "node=%p\n", cm_node); 592 598 cm_packets_bounced++; 593 599 atomic_dec(&send_entry->skb->users); 594 600 send_entry->retrycount--; 595 601 nexttimeout = jiffies + NES_SHORT_TIME; 596 602 settimer = 1; 597 - node_done = 1; 598 - spin_lock_irqsave(&cm_node->retrans_list_lock, flags); 599 603 continue; 600 604 } else { 601 605 cm_packets_sent++; 602 606 } 603 - spin_lock_irqsave(&cm_node->retrans_list_lock, flags); 604 - list_del(&send_entry->list); 605 - nes_debug(NES_DBG_CM, "Packet Sent: retrans count = %u, retry count = %u.\n", 606 - send_entry->retranscount, send_entry->retrycount); 607 + nes_debug(NES_DBG_CM, "Packet Sent: retrans count = " 608 + "%u, retry count = %u.\n", 609 + send_entry->retranscount, 610 + send_entry->retrycount); 607 611 if (send_entry->send_retrans) { 608 612 send_entry->retranscount--; 609 - send_entry->timetosend = jiffies + NES_RETRY_TIMEOUT; 610 - if (nexttimeout > send_entry->timetosend || !settimer) { 613 + send_entry->timetosend = jiffies + 614 + NES_RETRY_TIMEOUT; 615 + if (nexttimeout > send_entry->timetosend || 616 + !settimer) { 611 617 nexttimeout = send_entry->timetosend; 612 618 settimer = 1; 613 619 } 614 - list_add(&send_entry->list, &cm_node->retrans_list); 615 - continue; 616 620 } else { 617 621 int close_when_complete; 618 - skb = send_entry->skb; 619 - close_when_complete = send_entry->close_when_complete; 620 - spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags); 621 - if (close_when_complete) { 622 - BUG_ON(atomic_read(&cm_node->ref_count) == 1); 623 - rem_ref_cm_node(cm_core, cm_node); 624 - } 625 - dev_kfree_skb_any(skb); 626 - kfree(send_entry); 627 - spin_lock_irqsave(&cm_node->retrans_list_lock, flags); 628 - continue; 622 + close_when_complete = 623 + send_entry->close_when_complete; 624 + nes_debug(NES_DBG_CM, "cm_node=%p state=%d\n", 625 + cm_node, cm_node->state); 626 + free_retrans_entry(cm_node); 627 + if (close_when_complete) 628 + rem_ref_cm_node(cm_node->cm_core, 629 + cm_node); 629 630 } 630 - } 631 + } while (0); 632 + 631 633 spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags); 632 - 633 - rem_ref_cm_node(cm_core, cm_node); 634 - 634 + rem_ref_cm_node(cm_node->cm_core, cm_node); 635 635 spin_lock_irqsave(&cm_core->ht_lock, flags); 636 - if (ret != NETDEV_TX_OK) 636 + if (ret != NETDEV_TX_OK) { 637 + nes_debug(NES_DBG_CM, "rexmit failed for cm_node=%p\n", 638 + cm_node); 637 639 break; 640 + } 638 641 } 639 642 spin_unlock_irqrestore(&cm_core->ht_lock, flags); 640 643 ··· 636 667 /** 637 668 * send_syn 638 669 */ 639 - static int send_syn(struct nes_cm_node *cm_node, u32 sendack) 670 + static int send_syn(struct nes_cm_node *cm_node, u32 sendack, 671 + struct sk_buff *skb) 640 672 { 641 673 int ret; 642 674 int flags = SET_SYN; 643 - struct sk_buff *skb; 644 675 char optionsbuffer[sizeof(struct option_mss) + 645 - sizeof(struct option_windowscale) + 646 - sizeof(struct option_base) + 1]; 676 + sizeof(struct option_windowscale) + sizeof(struct option_base) + 677 + TCP_OPTIONS_PADDING]; 647 678 648 679 int optionssize = 0; 649 680 /* Sending MSS option */ ··· 664 695 options->as_windowscale.shiftcount = cm_node->tcp_cntxt.rcv_wscale; 665 696 optionssize += sizeof(struct option_windowscale); 666 697 667 - if (sendack && !(NES_DRV_OPT_SUPRESS_OPTION_BC & nes_drv_opt) 668 - ) { 698 + if (sendack && !(NES_DRV_OPT_SUPRESS_OPTION_BC & nes_drv_opt)) { 669 699 options = (union all_known_options *)&optionsbuffer[optionssize]; 670 700 options->as_base.optionnum = OPTION_NUMBER_WRITE0; 671 701 options->as_base.length = sizeof(struct option_base); ··· 682 714 options->as_end = OPTION_NUMBER_END; 683 715 optionssize += 1; 684 716 685 - skb = get_free_pkt(cm_node); 717 + if (!skb) 718 + skb = get_free_pkt(cm_node); 686 719 if (!skb) { 687 720 nes_debug(NES_DBG_CM, "Failed to get a Free pkt\n"); 688 721 return -1; ··· 702 733 /** 703 734 * send_reset 704 735 */ 705 - static int send_reset(struct nes_cm_node *cm_node) 736 + static int send_reset(struct nes_cm_node *cm_node, struct sk_buff *skb) 706 737 { 707 738 int ret; 708 - struct sk_buff *skb = get_free_pkt(cm_node); 709 739 int flags = SET_RST | SET_ACK; 710 740 741 + if (!skb) 742 + skb = get_free_pkt(cm_node); 711 743 if (!skb) { 712 744 nes_debug(NES_DBG_CM, "Failed to get a Free pkt\n"); 713 745 return -1; 714 746 } 715 747 716 - add_ref_cm_node(cm_node); 717 748 form_cm_frame(skb, cm_node, NULL, 0, NULL, 0, flags); 718 749 ret = schedule_nes_timer(cm_node, skb, NES_TIMER_TYPE_SEND, 0, 1); 719 750 ··· 724 755 /** 725 756 * send_ack 726 757 */ 727 - static int send_ack(struct nes_cm_node *cm_node) 758 + static int send_ack(struct nes_cm_node *cm_node, struct sk_buff *skb) 728 759 { 729 760 int ret; 730 - struct sk_buff *skb = get_free_pkt(cm_node); 761 + 762 + if (!skb) 763 + skb = get_free_pkt(cm_node); 731 764 732 765 if (!skb) { 733 766 nes_debug(NES_DBG_CM, "Failed to get a Free pkt\n"); ··· 893 922 if (!cm_node || !cm_core) 894 923 return -EINVAL; 895 924 896 - nes_debug(NES_DBG_CM, "Adding Node to Active Connection HT\n"); 925 + nes_debug(NES_DBG_CM, "Adding Node %p to Active Connection HT\n", 926 + cm_node); 897 927 898 928 /* first, make an index into our hash table */ 899 929 hashkey = make_hashkey(cm_node->loc_port, cm_node->loc_addr, ··· 918 946 * mini_cm_dec_refcnt_listen 919 947 */ 920 948 static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core, 921 - struct nes_cm_listener *listener, int free_hanging_nodes) 949 + struct nes_cm_listener *listener, int free_hanging_nodes) 922 950 { 923 951 int ret = 1; 924 952 unsigned long flags; 953 + struct list_head *list_pos = NULL; 954 + struct list_head *list_temp = NULL; 955 + struct nes_cm_node *cm_node = NULL; 956 + 957 + nes_debug(NES_DBG_CM, "attempting listener= %p free_nodes= %d, " 958 + "refcnt=%d\n", listener, free_hanging_nodes, 959 + atomic_read(&listener->ref_count)); 960 + /* free non-accelerated child nodes for this listener */ 961 + if (free_hanging_nodes) { 962 + spin_lock_irqsave(&cm_core->ht_lock, flags); 963 + list_for_each_safe(list_pos, list_temp, 964 + &g_cm_core->connected_nodes) { 965 + cm_node = container_of(list_pos, struct nes_cm_node, 966 + list); 967 + if ((cm_node->listener == listener) && 968 + (!cm_node->accelerated)) { 969 + cleanup_retrans_entry(cm_node); 970 + spin_unlock_irqrestore(&cm_core->ht_lock, 971 + flags); 972 + send_reset(cm_node, NULL); 973 + spin_lock_irqsave(&cm_core->ht_lock, flags); 974 + } 975 + } 976 + spin_unlock_irqrestore(&cm_core->ht_lock, flags); 977 + } 925 978 spin_lock_irqsave(&cm_core->listen_list_lock, flags); 926 979 if (!atomic_dec_return(&listener->ref_count)) { 927 980 list_del(&listener->list); ··· 1064 1067 cm_node->loc_port = cm_info->loc_port; 1065 1068 cm_node->rem_port = cm_info->rem_port; 1066 1069 cm_node->send_write0 = send_first; 1067 - nes_debug(NES_DBG_CM, "Make node addresses : loc = " NIPQUAD_FMT ":%x, rem = " NIPQUAD_FMT ":%x\n", 1068 - HIPQUAD(cm_node->loc_addr), cm_node->loc_port, 1069 - HIPQUAD(cm_node->rem_addr), cm_node->rem_port); 1070 + nes_debug(NES_DBG_CM, "Make node addresses : loc = " NIPQUAD_FMT 1071 + ":%x, rem = " NIPQUAD_FMT ":%x\n", 1072 + HIPQUAD(cm_node->loc_addr), cm_node->loc_port, 1073 + HIPQUAD(cm_node->rem_addr), cm_node->rem_port); 1070 1074 cm_node->listener = listener; 1071 1075 cm_node->netdev = nesvnic->netdev; 1072 1076 cm_node->cm_id = cm_info->cm_id; 1073 1077 memcpy(cm_node->loc_mac, nesvnic->netdev->dev_addr, ETH_ALEN); 1074 1078 1075 - nes_debug(NES_DBG_CM, "listener=%p, cm_id=%p\n", 1076 - cm_node->listener, cm_node->cm_id); 1079 + nes_debug(NES_DBG_CM, "listener=%p, cm_id=%p\n", cm_node->listener, 1080 + cm_node->cm_id); 1077 1081 1078 - INIT_LIST_HEAD(&cm_node->retrans_list); 1079 1082 spin_lock_init(&cm_node->retrans_list_lock); 1080 1083 INIT_LIST_HEAD(&cm_node->recv_list); 1081 1084 spin_lock_init(&cm_node->recv_list_lock); ··· 1139 1142 * rem_ref_cm_node - destroy an instance of a cm node 1140 1143 */ 1141 1144 static int rem_ref_cm_node(struct nes_cm_core *cm_core, 1142 - struct nes_cm_node *cm_node) 1145 + struct nes_cm_node *cm_node) 1143 1146 { 1144 1147 unsigned long flags, qplockflags; 1145 - struct nes_timer_entry *send_entry; 1146 1148 struct nes_timer_entry *recv_entry; 1147 1149 struct iw_cm_id *cm_id; 1148 1150 struct list_head *list_core, *list_node_temp; ··· 1165 1169 atomic_dec(&cm_node->listener->pend_accepts_cnt); 1166 1170 BUG_ON(atomic_read(&cm_node->listener->pend_accepts_cnt) < 0); 1167 1171 } 1168 - 1169 - spin_lock_irqsave(&cm_node->retrans_list_lock, flags); 1170 - list_for_each_safe(list_core, list_node_temp, &cm_node->retrans_list) { 1171 - send_entry = container_of(list_core, struct nes_timer_entry, list); 1172 - list_del(&send_entry->list); 1173 - spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags); 1174 - dev_kfree_skb_any(send_entry->skb); 1175 - kfree(send_entry); 1176 - spin_lock_irqsave(&cm_node->retrans_list_lock, flags); 1177 - continue; 1178 - } 1179 - spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags); 1180 - 1172 + BUG_ON(cm_node->send_entry); 1181 1173 spin_lock_irqsave(&cm_node->recv_list_lock, flags); 1182 1174 list_for_each_safe(list_core, list_node_temp, &cm_node->recv_list) { 1183 - recv_entry = container_of(list_core, struct nes_timer_entry, list); 1175 + recv_entry = container_of(list_core, struct nes_timer_entry, 1176 + list); 1184 1177 list_del(&recv_entry->list); 1185 1178 cm_id = cm_node->cm_id; 1186 1179 spin_unlock_irqrestore(&cm_node->recv_list_lock, flags); 1187 - if (recv_entry->type == NES_TIMER_TYPE_CLOSE) { 1188 - nesqp = (struct nes_qp *)recv_entry->skb; 1189 - spin_lock_irqsave(&nesqp->lock, qplockflags); 1190 - if (nesqp->cm_id) { 1191 - nes_debug(NES_DBG_CM, "QP%u: cm_id = %p: ****** HIT A NES_TIMER_TYPE_CLOSE" 1192 - " with something to do!!! ******\n", 1193 - nesqp->hwqp.qp_id, cm_id); 1194 - nesqp->hw_tcp_state = NES_AEQE_TCP_STATE_CLOSED; 1195 - nesqp->last_aeq = NES_AEQE_AEID_RESET_SENT; 1196 - nesqp->ibqp_state = IB_QPS_ERR; 1197 - spin_unlock_irqrestore(&nesqp->lock, qplockflags); 1198 - nes_cm_disconn(nesqp); 1199 - } else { 1200 - spin_unlock_irqrestore(&nesqp->lock, qplockflags); 1201 - nes_debug(NES_DBG_CM, "QP%u: cm_id = %p: ****** HIT A NES_TIMER_TYPE_CLOSE" 1202 - " with nothing to do!!! ******\n", 1203 - nesqp->hwqp.qp_id, cm_id); 1204 - nes_rem_ref(&nesqp->ibqp); 1205 - } 1206 - cm_id->rem_ref(cm_id); 1207 - } else if (recv_entry->type == NES_TIMER_TYPE_RECV) { 1208 - dev_kfree_skb_any(recv_entry->skb); 1180 + nesqp = (struct nes_qp *)recv_entry->skb; 1181 + spin_lock_irqsave(&nesqp->lock, qplockflags); 1182 + if (nesqp->cm_id) { 1183 + nes_debug(NES_DBG_CM, "QP%u: cm_id = %p: HIT A " 1184 + "NES_TIMER_TYPE_CLOSE with something to do!\n", 1185 + nesqp->hwqp.qp_id, cm_id); 1186 + nesqp->hw_tcp_state = NES_AEQE_TCP_STATE_CLOSED; 1187 + nesqp->last_aeq = NES_AEQE_AEID_RESET_SENT; 1188 + nesqp->ibqp_state = IB_QPS_ERR; 1189 + spin_unlock_irqrestore(&nesqp->lock, qplockflags); 1190 + nes_cm_disconn(nesqp); 1191 + } else { 1192 + spin_unlock_irqrestore(&nesqp->lock, qplockflags); 1193 + nes_debug(NES_DBG_CM, "QP%u: cm_id = %p: HIT A " 1194 + "NES_TIMER_TYPE_CLOSE with nothing to do!\n", 1195 + nesqp->hwqp.qp_id, cm_id); 1209 1196 } 1197 + cm_id->rem_ref(cm_id); 1198 + 1210 1199 kfree(recv_entry); 1211 1200 spin_lock_irqsave(&cm_node->recv_list_lock, flags); 1212 1201 } ··· 1202 1221 } else { 1203 1222 if (cm_node->apbvt_set && cm_node->nesvnic) { 1204 1223 nes_manage_apbvt(cm_node->nesvnic, cm_node->loc_port, 1205 - PCI_FUNC(cm_node->nesvnic->nesdev->pcidev->devfn), 1206 - NES_MANAGE_APBVT_DEL); 1224 + PCI_FUNC( 1225 + cm_node->nesvnic->nesdev->pcidev->devfn), 1226 + NES_MANAGE_APBVT_DEL); 1207 1227 } 1208 1228 } 1209 1229 1210 - kfree(cm_node); 1211 1230 atomic_dec(&cm_core->node_cnt); 1212 1231 atomic_inc(&cm_nodes_destroyed); 1232 + nesqp = cm_node->nesqp; 1233 + if (nesqp) { 1234 + nesqp->cm_node = NULL; 1235 + nes_rem_ref(&nesqp->ibqp); 1236 + cm_node->nesqp = NULL; 1237 + } 1213 1238 1239 + cm_node->freed = 1; 1240 + kfree(cm_node); 1214 1241 return 0; 1215 1242 } 1216 - 1217 1243 1218 1244 /** 1219 1245 * process_options 1220 1246 */ 1221 - static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc, u32 optionsize, u32 syn_packet) 1247 + static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc, 1248 + u32 optionsize, u32 syn_packet) 1222 1249 { 1223 1250 u32 tmp; 1224 1251 u32 offset = 0; ··· 1236 1247 while (offset < optionsize) { 1237 1248 all_options = (union all_known_options *)(optionsloc + offset); 1238 1249 switch (all_options->as_base.optionnum) { 1239 - case OPTION_NUMBER_END: 1240 - offset = optionsize; 1241 - break; 1242 - case OPTION_NUMBER_NONE: 1243 - offset += 1; 1244 - continue; 1245 - case OPTION_NUMBER_MSS: 1246 - nes_debug(NES_DBG_CM, "%s: MSS Length: %d Offset: %d Size: %d\n", 1247 - __func__, 1248 - all_options->as_mss.length, offset, optionsize); 1249 - got_mss_option = 1; 1250 - if (all_options->as_mss.length != 4) { 1251 - return 1; 1252 - } else { 1253 - tmp = ntohs(all_options->as_mss.mss); 1254 - if (tmp > 0 && tmp < cm_node->tcp_cntxt.mss) 1255 - cm_node->tcp_cntxt.mss = tmp; 1256 - } 1257 - break; 1258 - case OPTION_NUMBER_WINDOW_SCALE: 1259 - cm_node->tcp_cntxt.snd_wscale = all_options->as_windowscale.shiftcount; 1260 - break; 1261 - case OPTION_NUMBER_WRITE0: 1262 - cm_node->send_write0 = 1; 1263 - break; 1264 - default: 1265 - nes_debug(NES_DBG_CM, "TCP Option not understood: %x\n", 1266 - all_options->as_base.optionnum); 1267 - break; 1250 + case OPTION_NUMBER_END: 1251 + offset = optionsize; 1252 + break; 1253 + case OPTION_NUMBER_NONE: 1254 + offset += 1; 1255 + continue; 1256 + case OPTION_NUMBER_MSS: 1257 + nes_debug(NES_DBG_CM, "%s: MSS Length: %d Offset: %d " 1258 + "Size: %d\n", __func__, 1259 + all_options->as_mss.length, offset, optionsize); 1260 + got_mss_option = 1; 1261 + if (all_options->as_mss.length != 4) { 1262 + return 1; 1263 + } else { 1264 + tmp = ntohs(all_options->as_mss.mss); 1265 + if (tmp > 0 && tmp < 1266 + cm_node->tcp_cntxt.mss) 1267 + cm_node->tcp_cntxt.mss = tmp; 1268 + } 1269 + break; 1270 + case OPTION_NUMBER_WINDOW_SCALE: 1271 + cm_node->tcp_cntxt.snd_wscale = 1272 + all_options->as_windowscale.shiftcount; 1273 + break; 1274 + case OPTION_NUMBER_WRITE0: 1275 + cm_node->send_write0 = 1; 1276 + break; 1277 + default: 1278 + nes_debug(NES_DBG_CM, "TCP Option not understood: %x\n", 1279 + all_options->as_base.optionnum); 1280 + break; 1268 1281 } 1269 1282 offset += all_options->as_base.length; 1270 1283 } ··· 1275 1284 return 0; 1276 1285 } 1277 1286 1278 - 1279 - /** 1280 - * process_packet 1281 - */ 1282 - static int process_packet(struct nes_cm_node *cm_node, struct sk_buff *skb, 1283 - struct nes_cm_core *cm_core) 1287 + static void drop_packet(struct sk_buff *skb) 1284 1288 { 1285 - int optionsize; 1286 - int datasize; 1287 - int ret = 0; 1288 - struct tcphdr *tcph = tcp_hdr(skb); 1289 - u32 inc_sequence; 1290 - if (cm_node->state == NES_CM_STATE_SYN_SENT && tcph->syn) { 1291 - inc_sequence = ntohl(tcph->seq); 1292 - cm_node->tcp_cntxt.rcv_nxt = inc_sequence; 1289 + atomic_inc(&cm_accel_dropped_pkts); 1290 + dev_kfree_skb_any(skb); 1291 + } 1292 + 1293 + static void handle_fin_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb, 1294 + struct tcphdr *tcph) 1295 + { 1296 + atomic_inc(&cm_resets_recvd); 1297 + nes_debug(NES_DBG_CM, "Received FIN, cm_node = %p, state = %u. " 1298 + "refcnt=%d\n", cm_node, cm_node->state, 1299 + atomic_read(&cm_node->ref_count)); 1300 + cm_node->tcp_cntxt.rcv_nxt++; 1301 + cleanup_retrans_entry(cm_node); 1302 + switch (cm_node->state) { 1303 + case NES_CM_STATE_SYN_RCVD: 1304 + case NES_CM_STATE_SYN_SENT: 1305 + case NES_CM_STATE_ESTABLISHED: 1306 + case NES_CM_STATE_MPAREQ_SENT: 1307 + cm_node->state = NES_CM_STATE_LAST_ACK; 1308 + send_fin(cm_node, skb); 1309 + break; 1310 + case NES_CM_STATE_FIN_WAIT1: 1311 + cm_node->state = NES_CM_STATE_CLOSING; 1312 + send_ack(cm_node, skb); 1313 + break; 1314 + case NES_CM_STATE_FIN_WAIT2: 1315 + cm_node->state = NES_CM_STATE_TIME_WAIT; 1316 + send_ack(cm_node, skb); 1317 + cm_node->state = NES_CM_STATE_CLOSED; 1318 + break; 1319 + case NES_CM_STATE_TSA: 1320 + default: 1321 + nes_debug(NES_DBG_CM, "Error Rcvd FIN for node-%p state = %d\n", 1322 + cm_node, cm_node->state); 1323 + drop_packet(skb); 1324 + break; 1293 1325 } 1326 + } 1294 1327 1295 - if ((!tcph) || (cm_node->state == NES_CM_STATE_TSA)) { 1296 - BUG_ON(!tcph); 1297 - atomic_inc(&cm_accel_dropped_pkts); 1298 - return -1; 1328 + 1329 + static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb, 1330 + struct tcphdr *tcph) 1331 + { 1332 + 1333 + int reset = 0; /* whether to send reset in case of err.. */ 1334 + atomic_inc(&cm_resets_recvd); 1335 + nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u." 1336 + " refcnt=%d\n", cm_node, cm_node->state, 1337 + atomic_read(&cm_node->ref_count)); 1338 + cleanup_retrans_entry(cm_node); 1339 + switch (cm_node->state) { 1340 + case NES_CM_STATE_SYN_SENT: 1341 + case NES_CM_STATE_MPAREQ_SENT: 1342 + nes_debug(NES_DBG_CM, "%s[%u] create abort for cm_node=%p " 1343 + "listener=%p state=%d\n", __func__, __LINE__, cm_node, 1344 + cm_node->listener, cm_node->state); 1345 + active_open_err(cm_node, skb, reset); 1346 + break; 1347 + /* For PASSIVE open states, remove the cm_node event */ 1348 + case NES_CM_STATE_ESTABLISHED: 1349 + case NES_CM_STATE_SYN_RCVD: 1350 + case NES_CM_STATE_LISTENING: 1351 + nes_debug(NES_DBG_CM, "Bad state %s[%u]\n", __func__, __LINE__); 1352 + passive_open_err(cm_node, skb, reset); 1353 + break; 1354 + case NES_CM_STATE_TSA: 1355 + default: 1356 + break; 1299 1357 } 1358 + } 1300 1359 1301 - if (tcph->rst) { 1302 - atomic_inc(&cm_resets_recvd); 1303 - nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u. refcnt=%d\n", 1304 - cm_node, cm_node->state, atomic_read(&cm_node->ref_count)); 1305 - switch (cm_node->state) { 1306 - case NES_CM_STATE_LISTENING: 1307 - rem_ref_cm_node(cm_core, cm_node); 1308 - break; 1309 - case NES_CM_STATE_TSA: 1310 - case NES_CM_STATE_CLOSED: 1311 - break; 1312 - case NES_CM_STATE_SYN_RCVD: 1313 - nes_debug(NES_DBG_CM, "Received a reset for local 0x%08X:%04X," 1314 - " remote 0x%08X:%04X, node state = %u\n", 1315 - cm_node->loc_addr, cm_node->loc_port, 1316 - cm_node->rem_addr, cm_node->rem_port, 1317 - cm_node->state); 1318 - rem_ref_cm_node(cm_core, cm_node); 1319 - break; 1320 - case NES_CM_STATE_ONE_SIDE_ESTABLISHED: 1321 - case NES_CM_STATE_ESTABLISHED: 1322 - case NES_CM_STATE_MPAREQ_SENT: 1323 - default: 1324 - nes_debug(NES_DBG_CM, "Received a reset for local 0x%08X:%04X," 1325 - " remote 0x%08X:%04X, node state = %u refcnt=%d\n", 1326 - cm_node->loc_addr, cm_node->loc_port, 1327 - cm_node->rem_addr, cm_node->rem_port, 1328 - cm_node->state, atomic_read(&cm_node->ref_count)); 1329 - /* create event */ 1330 - cm_node->state = NES_CM_STATE_CLOSED; 1360 + static void handle_rcv_mpa(struct nes_cm_node *cm_node, struct sk_buff *skb, 1361 + enum nes_cm_event_type type) 1362 + { 1331 1363 1332 - create_event(cm_node, NES_CM_EVENT_ABORTED); 1333 - break; 1334 - 1364 + int ret; 1365 + int datasize = skb->len; 1366 + u8 *dataloc = skb->data; 1367 + ret = parse_mpa(cm_node, dataloc, datasize); 1368 + if (ret < 0) { 1369 + nes_debug(NES_DBG_CM, "didn't like MPA Request\n"); 1370 + if (type == NES_CM_EVENT_CONNECTED) { 1371 + nes_debug(NES_DBG_CM, "%s[%u] create abort for " 1372 + "cm_node=%p listener=%p state=%d\n", __func__, 1373 + __LINE__, cm_node, cm_node->listener, 1374 + cm_node->state); 1375 + active_open_err(cm_node, skb, 1); 1376 + } else { 1377 + passive_open_err(cm_node, skb, 1); 1335 1378 } 1336 - return -1; 1379 + } else { 1380 + cleanup_retrans_entry(cm_node); 1381 + dev_kfree_skb_any(skb); 1382 + if (type == NES_CM_EVENT_CONNECTED) 1383 + cm_node->state = NES_CM_STATE_TSA; 1384 + create_event(cm_node, type); 1385 + 1337 1386 } 1387 + return ; 1388 + } 1389 + 1390 + static void indicate_pkt_err(struct nes_cm_node *cm_node, struct sk_buff *skb) 1391 + { 1392 + switch (cm_node->state) { 1393 + case NES_CM_STATE_SYN_SENT: 1394 + case NES_CM_STATE_MPAREQ_SENT: 1395 + nes_debug(NES_DBG_CM, "%s[%u] create abort for cm_node=%p " 1396 + "listener=%p state=%d\n", __func__, __LINE__, cm_node, 1397 + cm_node->listener, cm_node->state); 1398 + active_open_err(cm_node, skb, 1); 1399 + break; 1400 + case NES_CM_STATE_ESTABLISHED: 1401 + case NES_CM_STATE_SYN_RCVD: 1402 + passive_open_err(cm_node, skb, 1); 1403 + break; 1404 + case NES_CM_STATE_TSA: 1405 + default: 1406 + drop_packet(skb); 1407 + } 1408 + } 1409 + 1410 + static int check_syn(struct nes_cm_node *cm_node, struct tcphdr *tcph, 1411 + struct sk_buff *skb) 1412 + { 1413 + int err; 1414 + 1415 + err = ((ntohl(tcph->ack_seq) == cm_node->tcp_cntxt.loc_seq_num))? 0 : 1; 1416 + if (err) 1417 + active_open_err(cm_node, skb, 1); 1418 + 1419 + return err; 1420 + } 1421 + 1422 + static int check_seq(struct nes_cm_node *cm_node, struct tcphdr *tcph, 1423 + struct sk_buff *skb) 1424 + { 1425 + int err = 0; 1426 + u32 seq; 1427 + u32 ack_seq; 1428 + u32 loc_seq_num = cm_node->tcp_cntxt.loc_seq_num; 1429 + u32 rcv_nxt = cm_node->tcp_cntxt.rcv_nxt; 1430 + u32 rcv_wnd; 1431 + seq = ntohl(tcph->seq); 1432 + ack_seq = ntohl(tcph->ack_seq); 1433 + rcv_wnd = cm_node->tcp_cntxt.rcv_wnd; 1434 + if (ack_seq != loc_seq_num) 1435 + err = 1; 1436 + else if ((seq + rcv_wnd) < rcv_nxt) 1437 + err = 1; 1438 + if (err) { 1439 + nes_debug(NES_DBG_CM, "%s[%u] create abort for cm_node=%p " 1440 + "listener=%p state=%d\n", __func__, __LINE__, cm_node, 1441 + cm_node->listener, cm_node->state); 1442 + indicate_pkt_err(cm_node, skb); 1443 + nes_debug(NES_DBG_CM, "seq ERROR cm_node =%p seq=0x%08X " 1444 + "rcv_nxt=0x%08X rcv_wnd=0x%x\n", cm_node, seq, rcv_nxt, 1445 + rcv_wnd); 1446 + } 1447 + return err; 1448 + } 1449 + 1450 + /* 1451 + * handle_syn_pkt() is for Passive node. The syn packet is received when a node 1452 + * is created with a listener or it may comein as rexmitted packet which in 1453 + * that case will be just dropped. 1454 + */ 1455 + 1456 + static void handle_syn_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb, 1457 + struct tcphdr *tcph) 1458 + { 1459 + int ret; 1460 + u32 inc_sequence; 1461 + int optionsize; 1338 1462 1339 1463 optionsize = (tcph->doff << 2) - sizeof(struct tcphdr); 1340 - 1341 - skb_pull(skb, ip_hdr(skb)->ihl << 2); 1342 1464 skb_pull(skb, tcph->doff << 2); 1343 - 1344 - datasize = skb->len; 1345 1465 inc_sequence = ntohl(tcph->seq); 1346 - nes_debug(NES_DBG_CM, "datasize = %u, sequence = 0x%08X, ack_seq = 0x%08X," 1347 - " rcv_nxt = 0x%08X Flags: %s %s.\n", 1348 - datasize, inc_sequence, ntohl(tcph->ack_seq), 1349 - cm_node->tcp_cntxt.rcv_nxt, (tcph->syn ? "SYN":""), 1350 - (tcph->ack ? "ACK":"")); 1351 1466 1352 - if (!tcph->syn && (inc_sequence != cm_node->tcp_cntxt.rcv_nxt) 1353 - ) { 1354 - nes_debug(NES_DBG_CM, "dropping packet, datasize = %u, sequence = 0x%08X," 1355 - " ack_seq = 0x%08X, rcv_nxt = 0x%08X Flags: %s.\n", 1356 - datasize, inc_sequence, ntohl(tcph->ack_seq), 1357 - cm_node->tcp_cntxt.rcv_nxt, (tcph->ack ? "ACK":"")); 1358 - if (cm_node->state == NES_CM_STATE_LISTENING) { 1359 - rem_ref_cm_node(cm_core, cm_node); 1467 + switch (cm_node->state) { 1468 + case NES_CM_STATE_SYN_SENT: 1469 + case NES_CM_STATE_MPAREQ_SENT: 1470 + /* Rcvd syn on active open connection*/ 1471 + active_open_err(cm_node, skb, 1); 1472 + break; 1473 + case NES_CM_STATE_LISTENING: 1474 + /* Passive OPEN */ 1475 + cm_node->accept_pend = 1; 1476 + atomic_inc(&cm_node->listener->pend_accepts_cnt); 1477 + if (atomic_read(&cm_node->listener->pend_accepts_cnt) > 1478 + cm_node->listener->backlog) { 1479 + nes_debug(NES_DBG_CM, "drop syn due to backlog " 1480 + "pressure \n"); 1481 + cm_backlog_drops++; 1482 + passive_open_err(cm_node, skb, 0); 1483 + break; 1360 1484 } 1361 - return -1; 1485 + ret = handle_tcp_options(cm_node, tcph, skb, optionsize, 1486 + 1); 1487 + if (ret) { 1488 + passive_open_err(cm_node, skb, 0); 1489 + /* drop pkt */ 1490 + break; 1491 + } 1492 + cm_node->tcp_cntxt.rcv_nxt = inc_sequence + 1; 1493 + BUG_ON(cm_node->send_entry); 1494 + cm_node->state = NES_CM_STATE_SYN_RCVD; 1495 + send_syn(cm_node, 1, skb); 1496 + break; 1497 + case NES_CM_STATE_TSA: 1498 + case NES_CM_STATE_ESTABLISHED: 1499 + case NES_CM_STATE_FIN_WAIT1: 1500 + case NES_CM_STATE_FIN_WAIT2: 1501 + case NES_CM_STATE_MPAREQ_RCVD: 1502 + case NES_CM_STATE_LAST_ACK: 1503 + case NES_CM_STATE_CLOSING: 1504 + case NES_CM_STATE_UNKNOWN: 1505 + case NES_CM_STATE_CLOSED: 1506 + default: 1507 + drop_packet(skb); 1508 + break; 1362 1509 } 1510 + } 1363 1511 1364 - cm_node->tcp_cntxt.rcv_nxt = inc_sequence + datasize; 1512 + static void handle_synack_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb, 1513 + struct tcphdr *tcph) 1514 + { 1365 1515 1516 + int ret; 1517 + u32 inc_sequence; 1518 + int optionsize; 1366 1519 1367 - if (optionsize) { 1368 - u8 *optionsloc = (u8 *)&tcph[1]; 1369 - if (process_options(cm_node, optionsloc, optionsize, (u32)tcph->syn)) { 1370 - nes_debug(NES_DBG_CM, "%s: Node %p, Sending RESET\n", __func__, cm_node); 1371 - send_reset(cm_node); 1372 - if (cm_node->state != NES_CM_STATE_SYN_SENT) 1373 - rem_ref_cm_node(cm_core, cm_node); 1374 - return 0; 1520 + optionsize = (tcph->doff << 2) - sizeof(struct tcphdr); 1521 + skb_pull(skb, tcph->doff << 2); 1522 + inc_sequence = ntohl(tcph->seq); 1523 + switch (cm_node->state) { 1524 + case NES_CM_STATE_SYN_SENT: 1525 + /* active open */ 1526 + if (check_syn(cm_node, tcph, skb)) 1527 + return; 1528 + cm_node->tcp_cntxt.rem_ack_num = ntohl(tcph->ack_seq); 1529 + /* setup options */ 1530 + ret = handle_tcp_options(cm_node, tcph, skb, optionsize, 0); 1531 + if (ret) { 1532 + nes_debug(NES_DBG_CM, "cm_node=%p tcp_options failed\n", 1533 + cm_node); 1534 + break; 1375 1535 } 1376 - } else if (tcph->syn) 1377 - cm_node->tcp_cntxt.mss = NES_CM_DEFAULT_MSS; 1536 + cleanup_retrans_entry(cm_node); 1537 + cm_node->tcp_cntxt.rcv_nxt = inc_sequence + 1; 1538 + send_mpa_request(cm_node, skb); 1539 + cm_node->state = NES_CM_STATE_MPAREQ_SENT; 1540 + break; 1541 + case NES_CM_STATE_MPAREQ_RCVD: 1542 + /* passive open, so should not be here */ 1543 + passive_open_err(cm_node, skb, 1); 1544 + break; 1545 + case NES_CM_STATE_ESTABLISHED: 1546 + case NES_CM_STATE_FIN_WAIT1: 1547 + case NES_CM_STATE_FIN_WAIT2: 1548 + case NES_CM_STATE_LAST_ACK: 1549 + case NES_CM_STATE_TSA: 1550 + case NES_CM_STATE_CLOSING: 1551 + case NES_CM_STATE_UNKNOWN: 1552 + case NES_CM_STATE_CLOSED: 1553 + case NES_CM_STATE_MPAREQ_SENT: 1554 + default: 1555 + drop_packet(skb); 1556 + break; 1557 + } 1558 + } 1559 + 1560 + static void handle_ack_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb, 1561 + struct tcphdr *tcph) 1562 + { 1563 + int datasize = 0; 1564 + u32 inc_sequence; 1565 + u32 rem_seq_ack; 1566 + u32 rem_seq; 1567 + if (check_seq(cm_node, tcph, skb)) 1568 + return; 1569 + 1570 + skb_pull(skb, tcph->doff << 2); 1571 + inc_sequence = ntohl(tcph->seq); 1572 + rem_seq = ntohl(tcph->seq); 1573 + rem_seq_ack = ntohl(tcph->ack_seq); 1574 + datasize = skb->len; 1575 + 1576 + switch (cm_node->state) { 1577 + case NES_CM_STATE_SYN_RCVD: 1578 + /* Passive OPEN */ 1579 + cm_node->tcp_cntxt.rem_ack_num = ntohl(tcph->ack_seq); 1580 + cm_node->state = NES_CM_STATE_ESTABLISHED; 1581 + if (datasize) { 1582 + cm_node->tcp_cntxt.rcv_nxt = inc_sequence + datasize; 1583 + cm_node->state = NES_CM_STATE_MPAREQ_RCVD; 1584 + handle_rcv_mpa(cm_node, skb, NES_CM_EVENT_MPA_REQ); 1585 + } else { /* rcvd ACK only */ 1586 + dev_kfree_skb_any(skb); 1587 + cleanup_retrans_entry(cm_node); 1588 + } 1589 + break; 1590 + case NES_CM_STATE_ESTABLISHED: 1591 + /* Passive OPEN */ 1592 + /* We expect mpa frame to be received only */ 1593 + if (datasize) { 1594 + cm_node->tcp_cntxt.rcv_nxt = inc_sequence + datasize; 1595 + cm_node->state = NES_CM_STATE_MPAREQ_RCVD; 1596 + handle_rcv_mpa(cm_node, skb, 1597 + NES_CM_EVENT_MPA_REQ); 1598 + } else 1599 + drop_packet(skb); 1600 + break; 1601 + case NES_CM_STATE_MPAREQ_SENT: 1602 + cm_node->tcp_cntxt.rem_ack_num = ntohl(tcph->ack_seq); 1603 + if (datasize) { 1604 + cm_node->tcp_cntxt.rcv_nxt = inc_sequence + datasize; 1605 + handle_rcv_mpa(cm_node, skb, NES_CM_EVENT_CONNECTED); 1606 + } else { /* Could be just an ack pkt.. */ 1607 + cleanup_retrans_entry(cm_node); 1608 + dev_kfree_skb_any(skb); 1609 + } 1610 + break; 1611 + case NES_CM_STATE_FIN_WAIT1: 1612 + case NES_CM_STATE_SYN_SENT: 1613 + case NES_CM_STATE_FIN_WAIT2: 1614 + case NES_CM_STATE_TSA: 1615 + case NES_CM_STATE_CLOSED: 1616 + case NES_CM_STATE_MPAREQ_RCVD: 1617 + case NES_CM_STATE_LAST_ACK: 1618 + case NES_CM_STATE_CLOSING: 1619 + case NES_CM_STATE_UNKNOWN: 1620 + default: 1621 + drop_packet(skb); 1622 + break; 1623 + } 1624 + } 1625 + 1626 + 1627 + 1628 + static int handle_tcp_options(struct nes_cm_node *cm_node, struct tcphdr *tcph, 1629 + struct sk_buff *skb, int optionsize, int passive) 1630 + { 1631 + u8 *optionsloc = (u8 *)&tcph[1]; 1632 + if (optionsize) { 1633 + if (process_options(cm_node, optionsloc, optionsize, 1634 + (u32)tcph->syn)) { 1635 + nes_debug(NES_DBG_CM, "%s: Node %p, Sending RESET\n", 1636 + __func__, cm_node); 1637 + if (passive) 1638 + passive_open_err(cm_node, skb, 0); 1639 + else 1640 + active_open_err(cm_node, skb, 0); 1641 + return 1; 1642 + } 1643 + } 1378 1644 1379 1645 cm_node->tcp_cntxt.snd_wnd = ntohs(tcph->window) << 1380 1646 cm_node->tcp_cntxt.snd_wscale; 1381 1647 1382 - if (cm_node->tcp_cntxt.snd_wnd > cm_node->tcp_cntxt.max_snd_wnd) { 1648 + if (cm_node->tcp_cntxt.snd_wnd > cm_node->tcp_cntxt.max_snd_wnd) 1383 1649 cm_node->tcp_cntxt.max_snd_wnd = cm_node->tcp_cntxt.snd_wnd; 1384 - } 1385 - 1386 - if (tcph->ack) { 1387 - cm_node->tcp_cntxt.rem_ack_num = ntohl(tcph->ack_seq); 1388 - switch (cm_node->state) { 1389 - case NES_CM_STATE_SYN_RCVD: 1390 - case NES_CM_STATE_SYN_SENT: 1391 - /* read and stash current sequence number */ 1392 - if (cm_node->tcp_cntxt.rem_ack_num != cm_node->tcp_cntxt.loc_seq_num) { 1393 - nes_debug(NES_DBG_CM, "ERROR - cm_node->tcp_cntxt.rem_ack_num !=" 1394 - " cm_node->tcp_cntxt.loc_seq_num\n"); 1395 - send_reset(cm_node); 1396 - return 0; 1397 - } 1398 - if (cm_node->state == NES_CM_STATE_SYN_SENT) 1399 - cm_node->state = NES_CM_STATE_ONE_SIDE_ESTABLISHED; 1400 - else { 1401 - cm_node->state = NES_CM_STATE_ESTABLISHED; 1402 - } 1403 - break; 1404 - case NES_CM_STATE_LAST_ACK: 1405 - cm_node->state = NES_CM_STATE_CLOSED; 1406 - break; 1407 - case NES_CM_STATE_FIN_WAIT1: 1408 - cm_node->state = NES_CM_STATE_FIN_WAIT2; 1409 - break; 1410 - case NES_CM_STATE_CLOSING: 1411 - cm_node->state = NES_CM_STATE_TIME_WAIT; 1412 - /* need to schedule this to happen in 2MSL timeouts */ 1413 - cm_node->state = NES_CM_STATE_CLOSED; 1414 - break; 1415 - case NES_CM_STATE_ONE_SIDE_ESTABLISHED: 1416 - case NES_CM_STATE_ESTABLISHED: 1417 - case NES_CM_STATE_MPAREQ_SENT: 1418 - case NES_CM_STATE_CLOSE_WAIT: 1419 - case NES_CM_STATE_TIME_WAIT: 1420 - case NES_CM_STATE_CLOSED: 1421 - break; 1422 - case NES_CM_STATE_LISTENING: 1423 - nes_debug(NES_DBG_CM, "Received an ACK on a listening port (SYN %d)\n", tcph->syn); 1424 - cm_node->tcp_cntxt.loc_seq_num = ntohl(tcph->ack_seq); 1425 - send_reset(cm_node); 1426 - /* send_reset bumps refcount, this should have been a new node */ 1427 - rem_ref_cm_node(cm_core, cm_node); 1428 - return -1; 1429 - break; 1430 - case NES_CM_STATE_TSA: 1431 - nes_debug(NES_DBG_CM, "Received a packet with the ack bit set while in TSA state\n"); 1432 - break; 1433 - case NES_CM_STATE_UNKNOWN: 1434 - case NES_CM_STATE_INITED: 1435 - case NES_CM_STATE_ACCEPTING: 1436 - case NES_CM_STATE_FIN_WAIT2: 1437 - default: 1438 - nes_debug(NES_DBG_CM, "Received ack from unknown state: %x\n", 1439 - cm_node->state); 1440 - send_reset(cm_node); 1441 - break; 1442 - } 1443 - } 1444 - 1445 - if (tcph->syn) { 1446 - if (cm_node->state == NES_CM_STATE_LISTENING) { 1447 - /* do not exceed backlog */ 1448 - atomic_inc(&cm_node->listener->pend_accepts_cnt); 1449 - if (atomic_read(&cm_node->listener->pend_accepts_cnt) > 1450 - cm_node->listener->backlog) { 1451 - nes_debug(NES_DBG_CM, "drop syn due to backlog pressure \n"); 1452 - cm_backlog_drops++; 1453 - atomic_dec(&cm_node->listener->pend_accepts_cnt); 1454 - rem_ref_cm_node(cm_core, cm_node); 1455 - return 0; 1456 - } 1457 - cm_node->accept_pend = 1; 1458 - 1459 - } 1460 - if (datasize == 0) 1461 - cm_node->tcp_cntxt.rcv_nxt ++; 1462 - 1463 - if (cm_node->state == NES_CM_STATE_LISTENING) { 1464 - cm_node->state = NES_CM_STATE_SYN_RCVD; 1465 - send_syn(cm_node, 1); 1466 - } 1467 - if (cm_node->state == NES_CM_STATE_ONE_SIDE_ESTABLISHED) { 1468 - cm_node->state = NES_CM_STATE_ESTABLISHED; 1469 - /* send final handshake ACK */ 1470 - ret = send_ack(cm_node); 1471 - if (ret < 0) 1472 - return ret; 1473 - 1474 - cm_node->state = NES_CM_STATE_MPAREQ_SENT; 1475 - ret = send_mpa_request(cm_node); 1476 - if (ret < 0) 1477 - return ret; 1478 - } 1479 - } 1480 - 1481 - if (tcph->fin) { 1482 - cm_node->tcp_cntxt.rcv_nxt++; 1483 - switch (cm_node->state) { 1484 - case NES_CM_STATE_SYN_RCVD: 1485 - case NES_CM_STATE_SYN_SENT: 1486 - case NES_CM_STATE_ONE_SIDE_ESTABLISHED: 1487 - case NES_CM_STATE_ESTABLISHED: 1488 - case NES_CM_STATE_ACCEPTING: 1489 - case NES_CM_STATE_MPAREQ_SENT: 1490 - cm_node->state = NES_CM_STATE_CLOSE_WAIT; 1491 - cm_node->state = NES_CM_STATE_LAST_ACK; 1492 - ret = send_fin(cm_node, NULL); 1493 - break; 1494 - case NES_CM_STATE_FIN_WAIT1: 1495 - cm_node->state = NES_CM_STATE_CLOSING; 1496 - ret = send_ack(cm_node); 1497 - break; 1498 - case NES_CM_STATE_FIN_WAIT2: 1499 - cm_node->state = NES_CM_STATE_TIME_WAIT; 1500 - cm_node->tcp_cntxt.loc_seq_num ++; 1501 - ret = send_ack(cm_node); 1502 - /* need to schedule this to happen in 2MSL timeouts */ 1503 - cm_node->state = NES_CM_STATE_CLOSED; 1504 - break; 1505 - case NES_CM_STATE_CLOSE_WAIT: 1506 - case NES_CM_STATE_LAST_ACK: 1507 - case NES_CM_STATE_CLOSING: 1508 - case NES_CM_STATE_TSA: 1509 - default: 1510 - nes_debug(NES_DBG_CM, "Received a fin while in %x state\n", 1511 - cm_node->state); 1512 - ret = -EINVAL; 1513 - break; 1514 - } 1515 - } 1516 - 1517 - if (datasize) { 1518 - u8 *dataloc = skb->data; 1519 - /* figure out what state we are in and handle transition to next state */ 1520 - switch (cm_node->state) { 1521 - case NES_CM_STATE_LISTENING: 1522 - case NES_CM_STATE_SYN_RCVD: 1523 - case NES_CM_STATE_SYN_SENT: 1524 - case NES_CM_STATE_FIN_WAIT1: 1525 - case NES_CM_STATE_FIN_WAIT2: 1526 - case NES_CM_STATE_CLOSE_WAIT: 1527 - case NES_CM_STATE_LAST_ACK: 1528 - case NES_CM_STATE_CLOSING: 1529 - break; 1530 - case NES_CM_STATE_MPAREQ_SENT: 1531 - /* recv the mpa res frame, ret=frame len (incl priv data) */ 1532 - ret = parse_mpa(cm_node, dataloc, datasize); 1533 - if (ret < 0) 1534 - break; 1535 - /* set the req frame payload len in skb */ 1536 - /* we are done handling this state, set node to a TSA state */ 1537 - cm_node->state = NES_CM_STATE_TSA; 1538 - send_ack(cm_node); 1539 - create_event(cm_node, NES_CM_EVENT_CONNECTED); 1540 - break; 1541 - 1542 - case NES_CM_STATE_ESTABLISHED: 1543 - /* we are expecting an MPA req frame */ 1544 - ret = parse_mpa(cm_node, dataloc, datasize); 1545 - if (ret < 0) { 1546 - break; 1547 - } 1548 - cm_node->state = NES_CM_STATE_TSA; 1549 - send_ack(cm_node); 1550 - /* we got a valid MPA request, create an event */ 1551 - create_event(cm_node, NES_CM_EVENT_MPA_REQ); 1552 - break; 1553 - case NES_CM_STATE_TSA: 1554 - handle_exception_pkt(cm_node, skb); 1555 - break; 1556 - case NES_CM_STATE_UNKNOWN: 1557 - case NES_CM_STATE_INITED: 1558 - default: 1559 - ret = -1; 1560 - } 1561 - } 1562 - 1563 - return ret; 1650 + return 0; 1564 1651 } 1565 1652 1653 + /* 1654 + * active_open_err() will send reset() if flag set.. 1655 + * It will also send ABORT event. 1656 + */ 1657 + 1658 + static void active_open_err(struct nes_cm_node *cm_node, struct sk_buff *skb, 1659 + int reset) 1660 + { 1661 + cleanup_retrans_entry(cm_node); 1662 + if (reset) { 1663 + nes_debug(NES_DBG_CM, "ERROR active err called for cm_node=%p, " 1664 + "state=%d\n", cm_node, cm_node->state); 1665 + add_ref_cm_node(cm_node); 1666 + send_reset(cm_node, skb); 1667 + } else 1668 + dev_kfree_skb_any(skb); 1669 + 1670 + cm_node->state = NES_CM_STATE_CLOSED; 1671 + create_event(cm_node, NES_CM_EVENT_ABORTED); 1672 + } 1673 + 1674 + /* 1675 + * passive_open_err() will either do a reset() or will free up the skb and 1676 + * remove the cm_node. 1677 + */ 1678 + 1679 + static void passive_open_err(struct nes_cm_node *cm_node, struct sk_buff *skb, 1680 + int reset) 1681 + { 1682 + cleanup_retrans_entry(cm_node); 1683 + cm_node->state = NES_CM_STATE_CLOSED; 1684 + if (reset) { 1685 + nes_debug(NES_DBG_CM, "passive_open_err sending RST for " 1686 + "cm_node=%p state =%d\n", cm_node, cm_node->state); 1687 + send_reset(cm_node, skb); 1688 + } else { 1689 + dev_kfree_skb_any(skb); 1690 + rem_ref_cm_node(cm_node->cm_core, cm_node); 1691 + } 1692 + } 1693 + 1694 + /* 1695 + * free_retrans_entry() routines assumes that the retrans_list_lock has 1696 + * been acquired before calling. 1697 + */ 1698 + static void free_retrans_entry(struct nes_cm_node *cm_node) 1699 + { 1700 + struct nes_timer_entry *send_entry; 1701 + send_entry = cm_node->send_entry; 1702 + if (send_entry) { 1703 + cm_node->send_entry = NULL; 1704 + dev_kfree_skb_any(send_entry->skb); 1705 + kfree(send_entry); 1706 + rem_ref_cm_node(cm_node->cm_core, cm_node); 1707 + } 1708 + } 1709 + 1710 + static void cleanup_retrans_entry(struct nes_cm_node *cm_node) 1711 + { 1712 + unsigned long flags; 1713 + 1714 + spin_lock_irqsave(&cm_node->retrans_list_lock, flags); 1715 + free_retrans_entry(cm_node); 1716 + spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags); 1717 + } 1718 + 1719 + /** 1720 + * process_packet 1721 + * Returns skb if to be freed, else it will return NULL if already used.. 1722 + */ 1723 + static void process_packet(struct nes_cm_node *cm_node, struct sk_buff *skb, 1724 + struct nes_cm_core *cm_core) 1725 + { 1726 + enum nes_tcpip_pkt_type pkt_type = NES_PKT_TYPE_UNKNOWN; 1727 + struct tcphdr *tcph = tcp_hdr(skb); 1728 + skb_pull(skb, ip_hdr(skb)->ihl << 2); 1729 + 1730 + nes_debug(NES_DBG_CM, "process_packet: cm_node=%p state =%d syn=%d " 1731 + "ack=%d rst=%d fin=%d\n", cm_node, cm_node->state, tcph->syn, 1732 + tcph->ack, tcph->rst, tcph->fin); 1733 + 1734 + if (tcph->rst) 1735 + pkt_type = NES_PKT_TYPE_RST; 1736 + else if (tcph->syn) { 1737 + pkt_type = NES_PKT_TYPE_SYN; 1738 + if (tcph->ack) 1739 + pkt_type = NES_PKT_TYPE_SYNACK; 1740 + } else if (tcph->fin) 1741 + pkt_type = NES_PKT_TYPE_FIN; 1742 + else if (tcph->ack) 1743 + pkt_type = NES_PKT_TYPE_ACK; 1744 + 1745 + switch (pkt_type) { 1746 + case NES_PKT_TYPE_SYN: 1747 + handle_syn_pkt(cm_node, skb, tcph); 1748 + break; 1749 + case NES_PKT_TYPE_SYNACK: 1750 + handle_synack_pkt(cm_node, skb, tcph); 1751 + break; 1752 + case NES_PKT_TYPE_ACK: 1753 + handle_ack_pkt(cm_node, skb, tcph); 1754 + break; 1755 + case NES_PKT_TYPE_RST: 1756 + handle_rst_pkt(cm_node, skb, tcph); 1757 + break; 1758 + case NES_PKT_TYPE_FIN: 1759 + handle_fin_pkt(cm_node, skb, tcph); 1760 + break; 1761 + default: 1762 + drop_packet(skb); 1763 + break; 1764 + } 1765 + } 1566 1766 1567 1767 /** 1568 1768 * mini_cm_listen - create a listen node with params 1569 1769 */ 1570 1770 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *cm_core, 1571 - struct nes_vnic *nesvnic, struct nes_cm_info *cm_info) 1771 + struct nes_vnic *nesvnic, struct nes_cm_info *cm_info) 1572 1772 { 1573 1773 struct nes_cm_listener *listener; 1574 1774 unsigned long flags; ··· 1826 1644 /** 1827 1645 * mini_cm_connect - make a connection node with params 1828 1646 */ 1829 - static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core, 1830 - struct nes_vnic *nesvnic, 1831 - struct ietf_mpa_frame *mpa_frame, 1832 - struct nes_cm_info *cm_info) 1647 + struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core, 1648 + struct nes_vnic *nesvnic, u16 private_data_len, 1649 + void *private_data, struct nes_cm_info *cm_info) 1833 1650 { 1834 1651 int ret = 0; 1835 1652 struct nes_cm_node *cm_node; 1836 1653 struct nes_cm_listener *loopbackremotelistener; 1837 1654 struct nes_cm_node *loopbackremotenode; 1838 1655 struct nes_cm_info loopback_cm_info; 1839 - 1840 - u16 mpa_frame_size = sizeof(struct ietf_mpa_frame) + 1841 - ntohs(mpa_frame->priv_data_len); 1842 - 1843 - cm_info->loc_addr = htonl(cm_info->loc_addr); 1844 - cm_info->rem_addr = htonl(cm_info->rem_addr); 1845 - cm_info->loc_port = htons(cm_info->loc_port); 1846 - cm_info->rem_port = htons(cm_info->rem_port); 1656 + u16 mpa_frame_size = sizeof(struct ietf_mpa_frame) + private_data_len; 1657 + struct ietf_mpa_frame *mpa_frame = NULL; 1847 1658 1848 1659 /* create a CM connection node */ 1849 1660 cm_node = make_cm_node(cm_core, nesvnic, cm_info, NULL); 1850 1661 if (!cm_node) 1851 1662 return NULL; 1663 + mpa_frame = &cm_node->mpa_frame; 1664 + strcpy(mpa_frame->key, IEFT_MPA_KEY_REQ); 1665 + mpa_frame->flags = IETF_MPA_FLAGS_CRC; 1666 + mpa_frame->rev = IETF_MPA_VERSION; 1667 + mpa_frame->priv_data_len = htons(private_data_len); 1852 1668 1853 1669 /* set our node side to client (active) side */ 1854 1670 cm_node->tcp_cntxt.client = 1; 1855 1671 cm_node->tcp_cntxt.rcv_wscale = NES_CM_DEFAULT_RCV_WND_SCALE; 1856 1672 1857 1673 if (cm_info->loc_addr == cm_info->rem_addr) { 1858 - loopbackremotelistener = find_listener(cm_core, cm_node->rem_addr, 1859 - cm_node->rem_port, NES_CM_LISTENER_ACTIVE_STATE); 1674 + loopbackremotelistener = find_listener(cm_core, 1675 + ntohl(nesvnic->local_ipaddr), cm_node->rem_port, 1676 + NES_CM_LISTENER_ACTIVE_STATE); 1860 1677 if (loopbackremotelistener == NULL) { 1861 1678 create_event(cm_node, NES_CM_EVENT_ABORTED); 1862 1679 } else { ··· 1864 1683 loopback_cm_info.loc_port = cm_info->rem_port; 1865 1684 loopback_cm_info.rem_port = cm_info->loc_port; 1866 1685 loopback_cm_info.cm_id = loopbackremotelistener->cm_id; 1867 - loopbackremotenode = make_cm_node(cm_core, nesvnic, &loopback_cm_info, 1868 - loopbackremotelistener); 1686 + loopbackremotenode = make_cm_node(cm_core, nesvnic, 1687 + &loopback_cm_info, loopbackremotelistener); 1869 1688 loopbackremotenode->loopbackpartner = cm_node; 1870 - loopbackremotenode->tcp_cntxt.rcv_wscale = NES_CM_DEFAULT_RCV_WND_SCALE; 1689 + loopbackremotenode->tcp_cntxt.rcv_wscale = 1690 + NES_CM_DEFAULT_RCV_WND_SCALE; 1871 1691 cm_node->loopbackpartner = loopbackremotenode; 1872 - memcpy(loopbackremotenode->mpa_frame_buf, &mpa_frame->priv_data, 1873 - mpa_frame_size); 1874 - loopbackremotenode->mpa_frame_size = mpa_frame_size - 1875 - sizeof(struct ietf_mpa_frame); 1692 + memcpy(loopbackremotenode->mpa_frame_buf, private_data, 1693 + private_data_len); 1694 + loopbackremotenode->mpa_frame_size = private_data_len; 1876 1695 1877 - /* we are done handling this state, set node to a TSA state */ 1696 + /* we are done handling this state. */ 1697 + /* set node to a TSA state */ 1878 1698 cm_node->state = NES_CM_STATE_TSA; 1879 - cm_node->tcp_cntxt.rcv_nxt = loopbackremotenode->tcp_cntxt.loc_seq_num; 1880 - loopbackremotenode->tcp_cntxt.rcv_nxt = cm_node->tcp_cntxt.loc_seq_num; 1881 - cm_node->tcp_cntxt.max_snd_wnd = loopbackremotenode->tcp_cntxt.rcv_wnd; 1882 - loopbackremotenode->tcp_cntxt.max_snd_wnd = cm_node->tcp_cntxt.rcv_wnd; 1883 - cm_node->tcp_cntxt.snd_wnd = loopbackremotenode->tcp_cntxt.rcv_wnd; 1884 - loopbackremotenode->tcp_cntxt.snd_wnd = cm_node->tcp_cntxt.rcv_wnd; 1885 - cm_node->tcp_cntxt.snd_wscale = loopbackremotenode->tcp_cntxt.rcv_wscale; 1886 - loopbackremotenode->tcp_cntxt.snd_wscale = cm_node->tcp_cntxt.rcv_wscale; 1699 + cm_node->tcp_cntxt.rcv_nxt = 1700 + loopbackremotenode->tcp_cntxt.loc_seq_num; 1701 + loopbackremotenode->tcp_cntxt.rcv_nxt = 1702 + cm_node->tcp_cntxt.loc_seq_num; 1703 + cm_node->tcp_cntxt.max_snd_wnd = 1704 + loopbackremotenode->tcp_cntxt.rcv_wnd; 1705 + loopbackremotenode->tcp_cntxt.max_snd_wnd = 1706 + cm_node->tcp_cntxt.rcv_wnd; 1707 + cm_node->tcp_cntxt.snd_wnd = 1708 + loopbackremotenode->tcp_cntxt.rcv_wnd; 1709 + loopbackremotenode->tcp_cntxt.snd_wnd = 1710 + cm_node->tcp_cntxt.rcv_wnd; 1711 + cm_node->tcp_cntxt.snd_wscale = 1712 + loopbackremotenode->tcp_cntxt.rcv_wscale; 1713 + loopbackremotenode->tcp_cntxt.snd_wscale = 1714 + cm_node->tcp_cntxt.rcv_wscale; 1887 1715 1888 1716 create_event(loopbackremotenode, NES_CM_EVENT_MPA_REQ); 1889 1717 } ··· 1902 1712 /* set our node side to client (active) side */ 1903 1713 cm_node->tcp_cntxt.client = 1; 1904 1714 /* init our MPA frame ptr */ 1905 - memcpy(&cm_node->mpa_frame, mpa_frame, mpa_frame_size); 1715 + memcpy(mpa_frame->priv_data, private_data, private_data_len); 1716 + 1906 1717 cm_node->mpa_frame_size = mpa_frame_size; 1907 1718 1908 1719 /* send a syn and goto syn sent state */ 1909 1720 cm_node->state = NES_CM_STATE_SYN_SENT; 1910 - ret = send_syn(cm_node, 0); 1721 + ret = send_syn(cm_node, 0, NULL); 1911 1722 1912 - nes_debug(NES_DBG_CM, "Api - connect(): dest addr=0x%08X, port=0x%04x," 1913 - " cm_node=%p, cm_id = %p.\n", 1914 - cm_node->rem_addr, cm_node->rem_port, cm_node, cm_node->cm_id); 1723 + if (ret) { 1724 + /* error in sending the syn free up the cm_node struct */ 1725 + nes_debug(NES_DBG_CM, "Api - connect() FAILED: dest " 1726 + "addr=0x%08X, port=0x%04x, cm_node=%p, cm_id = %p.\n", 1727 + cm_node->rem_addr, cm_node->rem_port, cm_node, 1728 + cm_node->cm_id); 1729 + rem_ref_cm_node(cm_node->cm_core, cm_node); 1730 + cm_node = NULL; 1731 + } 1732 + 1733 + if (cm_node) 1734 + nes_debug(NES_DBG_CM, "Api - connect(): dest addr=0x%08X," 1735 + "port=0x%04x, cm_node=%p, cm_id = %p.\n", 1736 + cm_node->rem_addr, cm_node->rem_port, cm_node, 1737 + cm_node->cm_id); 1915 1738 1916 1739 return cm_node; 1917 1740 } ··· 1934 1731 * mini_cm_accept - accept a connection 1935 1732 * This function is never called 1936 1733 */ 1937 - static int mini_cm_accept(struct nes_cm_core *cm_core, struct ietf_mpa_frame *mpa_frame, 1938 - struct nes_cm_node *cm_node) 1734 + static int mini_cm_accept(struct nes_cm_core *cm_core, 1735 + struct ietf_mpa_frame *mpa_frame, struct nes_cm_node *cm_node) 1939 1736 { 1940 1737 return 0; 1941 1738 } ··· 1945 1742 * mini_cm_reject - reject and teardown a connection 1946 1743 */ 1947 1744 static int mini_cm_reject(struct nes_cm_core *cm_core, 1948 - struct ietf_mpa_frame *mpa_frame, 1949 - struct nes_cm_node *cm_node) 1745 + struct ietf_mpa_frame *mpa_frame, struct nes_cm_node *cm_node) 1950 1746 { 1951 1747 int ret = 0; 1952 - struct sk_buff *skb; 1953 - u16 mpa_frame_size = sizeof(struct ietf_mpa_frame) + 1954 - ntohs(mpa_frame->priv_data_len); 1955 1748 1956 - skb = get_free_pkt(cm_node); 1957 - if (!skb) { 1958 - nes_debug(NES_DBG_CM, "Failed to get a Free pkt\n"); 1959 - return -1; 1960 - } 1749 + nes_debug(NES_DBG_CM, "%s cm_node=%p type=%d state=%d\n", 1750 + __func__, cm_node, cm_node->tcp_cntxt.client, cm_node->state); 1961 1751 1962 - /* send an MPA Request frame */ 1963 - form_cm_frame(skb, cm_node, NULL, 0, mpa_frame, mpa_frame_size, SET_ACK | SET_FIN); 1964 - ret = schedule_nes_timer(cm_node, skb, NES_TIMER_TYPE_SEND, 1, 0); 1965 - 1752 + if (cm_node->tcp_cntxt.client) 1753 + return ret; 1754 + cleanup_retrans_entry(cm_node); 1966 1755 cm_node->state = NES_CM_STATE_CLOSED; 1967 1756 ret = send_fin(cm_node, NULL); 1968 1757 1969 - if (ret < 0) { 1970 - printk(KERN_INFO PFX "failed to send MPA Reply (reject)\n"); 1971 - return ret; 1758 + if (cm_node->accept_pend) { 1759 + BUG_ON(!cm_node->listener); 1760 + atomic_dec(&cm_node->listener->pend_accepts_cnt); 1761 + BUG_ON(atomic_read(&cm_node->listener->pend_accepts_cnt) < 0); 1972 1762 } 1973 1763 1764 + ret = send_reset(cm_node, NULL); 1974 1765 return ret; 1975 1766 } 1976 1767 ··· 1980 1783 return -EINVAL; 1981 1784 1982 1785 switch (cm_node->state) { 1983 - /* if passed in node is null, create a reference key node for node search */ 1984 - /* check if we found an owner node for this pkt */ 1985 - case NES_CM_STATE_SYN_RCVD: 1986 - case NES_CM_STATE_SYN_SENT: 1987 - case NES_CM_STATE_ONE_SIDE_ESTABLISHED: 1988 - case NES_CM_STATE_ESTABLISHED: 1989 - case NES_CM_STATE_ACCEPTING: 1990 - case NES_CM_STATE_MPAREQ_SENT: 1991 - cm_node->state = NES_CM_STATE_FIN_WAIT1; 1992 - send_fin(cm_node, NULL); 1993 - break; 1994 - case NES_CM_STATE_CLOSE_WAIT: 1995 - cm_node->state = NES_CM_STATE_LAST_ACK; 1996 - send_fin(cm_node, NULL); 1997 - break; 1998 - case NES_CM_STATE_FIN_WAIT1: 1999 - case NES_CM_STATE_FIN_WAIT2: 2000 - case NES_CM_STATE_LAST_ACK: 2001 - case NES_CM_STATE_TIME_WAIT: 2002 - case NES_CM_STATE_CLOSING: 2003 - ret = -1; 2004 - break; 2005 - case NES_CM_STATE_LISTENING: 2006 - case NES_CM_STATE_UNKNOWN: 2007 - case NES_CM_STATE_INITED: 2008 - case NES_CM_STATE_CLOSED: 2009 - case NES_CM_STATE_TSA: 2010 - ret = rem_ref_cm_node(cm_core, cm_node); 2011 - break; 1786 + case NES_CM_STATE_SYN_RCVD: 1787 + case NES_CM_STATE_SYN_SENT: 1788 + case NES_CM_STATE_ONE_SIDE_ESTABLISHED: 1789 + case NES_CM_STATE_ESTABLISHED: 1790 + case NES_CM_STATE_ACCEPTING: 1791 + case NES_CM_STATE_MPAREQ_SENT: 1792 + case NES_CM_STATE_MPAREQ_RCVD: 1793 + cleanup_retrans_entry(cm_node); 1794 + send_reset(cm_node, NULL); 1795 + break; 1796 + case NES_CM_STATE_CLOSE_WAIT: 1797 + cm_node->state = NES_CM_STATE_LAST_ACK; 1798 + send_fin(cm_node, NULL); 1799 + break; 1800 + case NES_CM_STATE_FIN_WAIT1: 1801 + case NES_CM_STATE_FIN_WAIT2: 1802 + case NES_CM_STATE_LAST_ACK: 1803 + case NES_CM_STATE_TIME_WAIT: 1804 + case NES_CM_STATE_CLOSING: 1805 + ret = -1; 1806 + break; 1807 + case NES_CM_STATE_LISTENING: 1808 + case NES_CM_STATE_UNKNOWN: 1809 + case NES_CM_STATE_INITED: 1810 + case NES_CM_STATE_CLOSED: 1811 + ret = rem_ref_cm_node(cm_core, cm_node); 1812 + break; 1813 + case NES_CM_STATE_TSA: 1814 + if (cm_node->send_entry) 1815 + printk(KERN_ERR "ERROR Close got called from STATE_TSA " 1816 + "send_entry=%p\n", cm_node->send_entry); 1817 + ret = rem_ref_cm_node(cm_core, cm_node); 1818 + break; 2012 1819 } 2013 1820 cm_node->cm_id = NULL; 2014 1821 return ret; ··· 2023 1822 * recv_pkt - recv an ETHERNET packet, and process it through CM 2024 1823 * node state machine 2025 1824 */ 2026 - static int mini_cm_recv_pkt(struct nes_cm_core *cm_core, struct nes_vnic *nesvnic, 2027 - struct sk_buff *skb) 1825 + static void mini_cm_recv_pkt(struct nes_cm_core *cm_core, 1826 + struct nes_vnic *nesvnic, struct sk_buff *skb) 2028 1827 { 2029 1828 struct nes_cm_node *cm_node = NULL; 2030 1829 struct nes_cm_listener *listener = NULL; 2031 1830 struct iphdr *iph; 2032 1831 struct tcphdr *tcph; 2033 1832 struct nes_cm_info nfo; 2034 - int ret = 0; 2035 1833 2036 - if (!skb || skb->len < sizeof(struct iphdr) + sizeof(struct tcphdr)) { 2037 - ret = -EINVAL; 2038 - goto out; 1834 + if (!skb) 1835 + return; 1836 + if (skb->len < sizeof(struct iphdr) + sizeof(struct tcphdr)) { 1837 + dev_kfree_skb_any(skb); 1838 + return; 2039 1839 } 2040 1840 2041 1841 iph = (struct iphdr *)skb->data; 2042 1842 tcph = (struct tcphdr *)(skb->data + sizeof(struct iphdr)); 2043 1843 skb_reset_network_header(skb); 2044 1844 skb_set_transport_header(skb, sizeof(*tcph)); 1845 + if (!tcph) { 1846 + dev_kfree_skb_any(skb); 1847 + return; 1848 + } 2045 1849 skb->len = ntohs(iph->tot_len); 2046 1850 2047 1851 nfo.loc_addr = ntohl(iph->daddr); ··· 2059 1853 NIPQUAD(iph->daddr), tcph->dest, 2060 1854 NIPQUAD(iph->saddr), tcph->source); 2061 1855 2062 - /* note: this call is going to increment cm_node ref count */ 2063 - cm_node = find_node(cm_core, 1856 + do { 1857 + cm_node = find_node(cm_core, 2064 1858 nfo.rem_port, nfo.rem_addr, 2065 1859 nfo.loc_port, nfo.loc_addr); 2066 1860 2067 - if (!cm_node) { 2068 - listener = find_listener(cm_core, nfo.loc_addr, nfo.loc_port, 2069 - NES_CM_LISTENER_ACTIVE_STATE); 2070 - if (listener) { 2071 - nfo.cm_id = listener->cm_id; 2072 - nfo.conn_type = listener->conn_type; 2073 - } else { 2074 - nfo.cm_id = NULL; 2075 - nfo.conn_type = 0; 2076 - } 2077 - 2078 - cm_node = make_cm_node(cm_core, nesvnic, &nfo, listener); 2079 1861 if (!cm_node) { 2080 - nes_debug(NES_DBG_CM, "Unable to allocate node\n"); 1862 + /* Only type of packet accepted are for */ 1863 + /* the PASSIVE open (syn only) */ 1864 + if ((!tcph->syn) || (tcph->ack)) { 1865 + cm_packets_dropped++; 1866 + break; 1867 + } 1868 + listener = find_listener(cm_core, nfo.loc_addr, 1869 + nfo.loc_port, 1870 + NES_CM_LISTENER_ACTIVE_STATE); 2081 1871 if (listener) { 2082 - nes_debug(NES_DBG_CM, "unable to allocate node and decrementing listener refcount\n"); 1872 + nfo.cm_id = listener->cm_id; 1873 + nfo.conn_type = listener->conn_type; 1874 + } else { 1875 + nes_debug(NES_DBG_CM, "Unable to find listener " 1876 + "for the pkt\n"); 1877 + cm_packets_dropped++; 1878 + dev_kfree_skb_any(skb); 1879 + break; 1880 + } 1881 + 1882 + cm_node = make_cm_node(cm_core, nesvnic, &nfo, 1883 + listener); 1884 + if (!cm_node) { 1885 + nes_debug(NES_DBG_CM, "Unable to allocate " 1886 + "node\n"); 1887 + cm_packets_dropped++; 2083 1888 atomic_dec(&listener->ref_count); 1889 + dev_kfree_skb_any(skb); 1890 + break; 2084 1891 } 2085 - ret = -1; 2086 - goto out; 2087 - } 2088 - if (!listener) { 2089 - nes_debug(NES_DBG_CM, "Packet found for unknown port %x refcnt=%d\n", 2090 - nfo.loc_port, atomic_read(&cm_node->ref_count)); 2091 - if (!tcph->rst) { 2092 - nes_debug(NES_DBG_CM, "Packet found for unknown port=%d" 2093 - " rem_port=%d refcnt=%d\n", 2094 - nfo.loc_port, nfo.rem_port, atomic_read(&cm_node->ref_count)); 2095 - 2096 - cm_node->tcp_cntxt.rcv_nxt = ntohl(tcph->seq); 2097 - cm_node->tcp_cntxt.loc_seq_num = ntohl(tcph->ack_seq); 2098 - send_reset(cm_node); 1892 + if (!tcph->rst && !tcph->fin) { 1893 + cm_node->state = NES_CM_STATE_LISTENING; 1894 + } else { 1895 + cm_packets_dropped++; 1896 + rem_ref_cm_node(cm_core, cm_node); 1897 + dev_kfree_skb_any(skb); 1898 + break; 2099 1899 } 1900 + add_ref_cm_node(cm_node); 1901 + } else if (cm_node->state == NES_CM_STATE_TSA) { 2100 1902 rem_ref_cm_node(cm_core, cm_node); 2101 - ret = -1; 2102 - goto out; 1903 + atomic_inc(&cm_accel_dropped_pkts); 1904 + dev_kfree_skb_any(skb); 1905 + break; 2103 1906 } 2104 - add_ref_cm_node(cm_node); 2105 - cm_node->state = NES_CM_STATE_LISTENING; 2106 - } 2107 - 2108 - nes_debug(NES_DBG_CM, "Processing Packet for node %p, data = (%p):\n", 2109 - cm_node, skb->data); 2110 - process_packet(cm_node, skb, cm_core); 2111 - 2112 - rem_ref_cm_node(cm_core, cm_node); 2113 - out: 2114 - if (skb) 2115 - dev_kfree_skb_any(skb); 2116 - return ret; 1907 + process_packet(cm_node, skb, cm_core); 1908 + rem_ref_cm_node(cm_core, cm_node); 1909 + } while (0); 2117 1910 } 2118 1911 2119 1912 ··· 2312 2107 if (nesqp->disconn_pending == 0) { 2313 2108 nesqp->disconn_pending++; 2314 2109 spin_unlock_irqrestore(&nesqp->lock, flags); 2315 - /* nes_add_ref(&nesqp->ibqp); */ 2316 2110 /* init our disconnect work element, to */ 2317 2111 INIT_WORK(&nesqp->disconn_work, nes_disconnect_worker); 2318 2112 2319 2113 queue_work(g_cm_core->disconn_wq, &nesqp->disconn_work); 2320 - } else { 2114 + } else 2321 2115 spin_unlock_irqrestore(&nesqp->lock, flags); 2322 - nes_rem_ref(&nesqp->ibqp); 2323 - } 2324 2116 2325 2117 return 0; 2326 2118 } ··· 2363 2161 nes_debug(NES_DBG_CM, "QP%u disconnect_worker cmid is NULL\n", 2364 2162 nesqp->hwqp.qp_id); 2365 2163 spin_unlock_irqrestore(&nesqp->lock, flags); 2366 - nes_rem_ref(&nesqp->ibqp); 2367 2164 return -1; 2368 2165 } 2369 2166 ··· 2383 2182 atomic_inc(&cm_disconnects); 2384 2183 cm_event.event = IW_CM_EVENT_DISCONNECT; 2385 2184 if (last_ae == NES_AEQE_AEID_LLP_CONNECTION_RESET) { 2386 - issued_disconnect_reset = 1; 2387 2185 cm_event.status = IW_CM_EVENT_STATUS_RESET; 2388 - nes_debug(NES_DBG_CM, "Generating a CM Disconnect Event (status reset) for " 2389 - " QP%u, cm_id = %p. \n", 2390 - nesqp->hwqp.qp_id, cm_id); 2391 - } else { 2186 + nes_debug(NES_DBG_CM, "Generating a CM " 2187 + "Disconnect Event (status reset) for " 2188 + "QP%u, cm_id = %p. \n", 2189 + nesqp->hwqp.qp_id, cm_id); 2190 + } else 2392 2191 cm_event.status = IW_CM_EVENT_STATUS_OK; 2393 - } 2394 2192 2395 2193 cm_event.local_addr = cm_id->local_addr; 2396 2194 cm_event.remote_addr = cm_id->remote_addr; 2397 2195 cm_event.private_data = NULL; 2398 2196 cm_event.private_data_len = 0; 2399 2197 2400 - nes_debug(NES_DBG_CM, "Generating a CM Disconnect Event for " 2401 - " QP%u, SQ Head = %u, SQ Tail = %u. cm_id = %p, refcount = %u.\n", 2402 - nesqp->hwqp.qp_id, 2403 - nesqp->hwqp.sq_head, nesqp->hwqp.sq_tail, cm_id, 2404 - atomic_read(&nesqp->refcount)); 2198 + nes_debug(NES_DBG_CM, "Generating a CM Disconnect Event" 2199 + " for QP%u, SQ Head = %u, SQ Tail = %u. " 2200 + "cm_id = %p, refcount = %u.\n", 2201 + nesqp->hwqp.qp_id, nesqp->hwqp.sq_head, 2202 + nesqp->hwqp.sq_tail, cm_id, 2203 + atomic_read(&nesqp->refcount)); 2405 2204 2406 2205 spin_unlock_irqrestore(&nesqp->lock, flags); 2407 2206 ret = cm_id->event_handler(cm_id, &cm_event); 2408 2207 if (ret) 2409 - nes_debug(NES_DBG_CM, "OFA CM event_handler returned, ret=%d\n", ret); 2208 + nes_debug(NES_DBG_CM, "OFA CM event_handler " 2209 + "returned, ret=%d\n", ret); 2410 2210 spin_lock_irqsave(&nesqp->lock, flags); 2411 2211 } 2412 2212 ··· 2449 2247 if (nesqp->flush_issued == 0) { 2450 2248 nesqp->flush_issued = 1; 2451 2249 spin_unlock_irqrestore(&nesqp->lock, flags); 2452 - flush_wqes(nesvnic->nesdev, nesqp, NES_CQP_FLUSH_RQ, 1); 2453 - } else { 2250 + flush_wqes(nesvnic->nesdev, nesqp, 2251 + NES_CQP_FLUSH_RQ, 1); 2252 + } else 2454 2253 spin_unlock_irqrestore(&nesqp->lock, flags); 2455 - } 2456 - 2457 - /* This reference is from either ModifyQP or the AE processing, 2458 - there is still a race here with modifyqp */ 2459 - nes_rem_ref(&nesqp->ibqp); 2460 - 2461 2254 } else { 2462 2255 cm_id = nesqp->cm_id; 2463 2256 spin_unlock_irqrestore(&nesqp->lock, flags); 2464 2257 /* check to see if the inbound reset beat the outbound reset */ 2465 2258 if ((!cm_id) && (last_ae==NES_AEQE_AEID_RESET_SENT)) { 2466 - nes_debug(NES_DBG_CM, "QP%u: Decing refcount due to inbound reset" 2467 - " beating the outbound reset.\n", 2468 - nesqp->hwqp.qp_id); 2469 - nes_rem_ref(&nesqp->ibqp); 2259 + nes_debug(NES_DBG_CM, "QP%u: Decing refcount " 2260 + "due to inbound reset beating the " 2261 + "outbound reset.\n", nesqp->hwqp.qp_id); 2470 2262 } 2471 2263 } 2472 2264 } else { 2473 2265 nesqp->disconn_pending = 0; 2474 2266 spin_unlock_irqrestore(&nesqp->lock, flags); 2475 2267 } 2476 - nes_rem_ref(&nesqp->ibqp); 2477 2268 2478 2269 return 0; 2479 2270 } ··· 2544 2349 nesdev = nesvnic->nesdev; 2545 2350 adapter = nesdev->nesadapter; 2546 2351 2547 - nes_debug(NES_DBG_CM, "nesvnic=%p, netdev=%p, %s\n", 2548 - nesvnic, nesvnic->netdev, nesvnic->netdev->name); 2549 - 2550 - /* since this is from a listen, we were able to put node handle into cm_id */ 2551 2352 cm_node = (struct nes_cm_node *)cm_id->provider_data; 2353 + nes_debug(NES_DBG_CM, "nes_accept: cm_node= %p nesvnic=%p, netdev=%p," 2354 + "%s\n", cm_node, nesvnic, nesvnic->netdev, 2355 + nesvnic->netdev->name); 2552 2356 2553 2357 /* associate the node with the QP */ 2554 2358 nesqp->cm_node = (void *)cm_node; 2359 + cm_node->nesqp = nesqp; 2360 + nes_add_ref(&nesqp->ibqp); 2555 2361 2556 - nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu\n", 2557 - nesqp->hwqp.qp_id, cm_node, jiffies); 2362 + nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n", 2363 + nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener); 2558 2364 atomic_inc(&cm_accepts); 2559 2365 2560 2366 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n", 2561 2367 atomic_read(&nesvnic->netdev->refcnt)); 2562 2368 2563 - /* allocate the ietf frame and space for private data */ 2564 - nesqp->ietf_frame = pci_alloc_consistent(nesdev->pcidev, 2565 - sizeof(struct ietf_mpa_frame) + conn_param->private_data_len, 2566 - &nesqp->ietf_frame_pbase); 2369 + /* allocate the ietf frame and space for private data */ 2370 + nesqp->ietf_frame = pci_alloc_consistent(nesdev->pcidev, 2371 + sizeof(struct ietf_mpa_frame) + conn_param->private_data_len, 2372 + &nesqp->ietf_frame_pbase); 2567 2373 2568 - if (!nesqp->ietf_frame) { 2569 - nes_debug(NES_DBG_CM, "Unable to allocate memory for private data\n"); 2570 - return -ENOMEM; 2571 - } 2374 + if (!nesqp->ietf_frame) { 2375 + nes_debug(NES_DBG_CM, "Unable to allocate memory for private " 2376 + "data\n"); 2377 + return -ENOMEM; 2378 + } 2572 2379 2573 2380 2574 - /* setup the MPA frame */ 2575 - nesqp->private_data_len = conn_param->private_data_len; 2576 - memcpy(nesqp->ietf_frame->key, IEFT_MPA_KEY_REP, IETF_MPA_KEY_SIZE); 2381 + /* setup the MPA frame */ 2382 + nesqp->private_data_len = conn_param->private_data_len; 2383 + memcpy(nesqp->ietf_frame->key, IEFT_MPA_KEY_REP, IETF_MPA_KEY_SIZE); 2577 2384 2578 - memcpy(nesqp->ietf_frame->priv_data, conn_param->private_data, 2579 - conn_param->private_data_len); 2385 + memcpy(nesqp->ietf_frame->priv_data, conn_param->private_data, 2386 + conn_param->private_data_len); 2580 2387 2581 - nesqp->ietf_frame->priv_data_len = cpu_to_be16(conn_param->private_data_len); 2582 - nesqp->ietf_frame->rev = mpa_version; 2583 - nesqp->ietf_frame->flags = IETF_MPA_FLAGS_CRC; 2388 + nesqp->ietf_frame->priv_data_len = 2389 + cpu_to_be16(conn_param->private_data_len); 2390 + nesqp->ietf_frame->rev = mpa_version; 2391 + nesqp->ietf_frame->flags = IETF_MPA_FLAGS_CRC; 2584 2392 2585 - /* setup our first outgoing iWarp send WQE (the IETF frame response) */ 2586 - wqe = &nesqp->hwqp.sq_vbase[0]; 2393 + /* setup our first outgoing iWarp send WQE (the IETF frame response) */ 2394 + wqe = &nesqp->hwqp.sq_vbase[0]; 2587 2395 2588 - if (cm_id->remote_addr.sin_addr.s_addr != cm_id->local_addr.sin_addr.s_addr) { 2589 - u64temp = (unsigned long)nesqp; 2590 - u64temp |= NES_SW_CONTEXT_ALIGN>>1; 2591 - set_wqe_64bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_COMP_CTX_LOW_IDX, 2592 - u64temp); 2593 - wqe->wqe_words[NES_IWARP_SQ_WQE_MISC_IDX] = 2594 - cpu_to_le32(NES_IWARP_SQ_WQE_STREAMING | NES_IWARP_SQ_WQE_WRPDU); 2595 - wqe->wqe_words[NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX] = 2596 - cpu_to_le32(conn_param->private_data_len + sizeof(struct ietf_mpa_frame)); 2597 - wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_LOW_IDX] = 2598 - cpu_to_le32((u32)nesqp->ietf_frame_pbase); 2599 - wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_HIGH_IDX] = 2600 - cpu_to_le32((u32)((u64)nesqp->ietf_frame_pbase >> 32)); 2601 - wqe->wqe_words[NES_IWARP_SQ_WQE_LENGTH0_IDX] = 2602 - cpu_to_le32(conn_param->private_data_len + sizeof(struct ietf_mpa_frame)); 2603 - wqe->wqe_words[NES_IWARP_SQ_WQE_STAG0_IDX] = 0; 2396 + if (cm_id->remote_addr.sin_addr.s_addr != 2397 + cm_id->local_addr.sin_addr.s_addr) { 2398 + u64temp = (unsigned long)nesqp; 2399 + u64temp |= NES_SW_CONTEXT_ALIGN>>1; 2400 + set_wqe_64bit_value(wqe->wqe_words, 2401 + NES_IWARP_SQ_WQE_COMP_CTX_LOW_IDX, 2402 + u64temp); 2403 + wqe->wqe_words[NES_IWARP_SQ_WQE_MISC_IDX] = 2404 + cpu_to_le32(NES_IWARP_SQ_WQE_STREAMING | 2405 + NES_IWARP_SQ_WQE_WRPDU); 2406 + wqe->wqe_words[NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX] = 2407 + cpu_to_le32(conn_param->private_data_len + 2408 + sizeof(struct ietf_mpa_frame)); 2409 + wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_LOW_IDX] = 2410 + cpu_to_le32((u32)nesqp->ietf_frame_pbase); 2411 + wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_HIGH_IDX] = 2412 + cpu_to_le32((u32)((u64)nesqp->ietf_frame_pbase >> 32)); 2413 + wqe->wqe_words[NES_IWARP_SQ_WQE_LENGTH0_IDX] = 2414 + cpu_to_le32(conn_param->private_data_len + 2415 + sizeof(struct ietf_mpa_frame)); 2416 + wqe->wqe_words[NES_IWARP_SQ_WQE_STAG0_IDX] = 0; 2604 2417 2605 - nesqp->nesqp_context->ird_ord_sizes |= cpu_to_le32( 2606 - NES_QPCONTEXT_ORDIRD_LSMM_PRESENT | NES_QPCONTEXT_ORDIRD_WRPDU); 2607 - } else { 2608 - nesqp->nesqp_context->ird_ord_sizes |= cpu_to_le32((NES_QPCONTEXT_ORDIRD_LSMM_PRESENT | 2609 - NES_QPCONTEXT_ORDIRD_WRPDU | NES_QPCONTEXT_ORDIRD_ALSMM)); 2610 - } 2611 - nesqp->skip_lsmm = 1; 2418 + nesqp->nesqp_context->ird_ord_sizes |= 2419 + cpu_to_le32(NES_QPCONTEXT_ORDIRD_LSMM_PRESENT | 2420 + NES_QPCONTEXT_ORDIRD_WRPDU); 2421 + } else { 2422 + nesqp->nesqp_context->ird_ord_sizes |= 2423 + cpu_to_le32((NES_QPCONTEXT_ORDIRD_LSMM_PRESENT | 2424 + NES_QPCONTEXT_ORDIRD_WRPDU | 2425 + NES_QPCONTEXT_ORDIRD_ALSMM)); 2426 + } 2427 + nesqp->skip_lsmm = 1; 2612 2428 2613 2429 2614 2430 /* Cache the cm_id in the qp */ ··· 2630 2424 cm_id->provider_data = nesqp; 2631 2425 nesqp->active_conn = 0; 2632 2426 2427 + if (cm_node->state == NES_CM_STATE_TSA) 2428 + nes_debug(NES_DBG_CM, "Already state = TSA for cm_node=%p\n", 2429 + cm_node); 2430 + 2633 2431 nes_cm_init_tsa_conn(nesqp, cm_node); 2634 2432 2635 - nesqp->nesqp_context->tcpPorts[0] = cpu_to_le16(ntohs(cm_id->local_addr.sin_port)); 2636 - nesqp->nesqp_context->tcpPorts[1] = cpu_to_le16(ntohs(cm_id->remote_addr.sin_port)); 2637 - nesqp->nesqp_context->ip0 = cpu_to_le32(ntohl(cm_id->remote_addr.sin_addr.s_addr)); 2433 + nesqp->nesqp_context->tcpPorts[0] = 2434 + cpu_to_le16(ntohs(cm_id->local_addr.sin_port)); 2435 + nesqp->nesqp_context->tcpPorts[1] = 2436 + cpu_to_le16(ntohs(cm_id->remote_addr.sin_port)); 2437 + 2438 + if (ipv4_is_loopback(cm_id->remote_addr.sin_addr.s_addr)) 2439 + nesqp->nesqp_context->ip0 = 2440 + cpu_to_le32(ntohl(nesvnic->local_ipaddr)); 2441 + else 2442 + nesqp->nesqp_context->ip0 = 2443 + cpu_to_le32(ntohl(cm_id->remote_addr.sin_addr.s_addr)); 2638 2444 2639 2445 nesqp->nesqp_context->misc2 |= cpu_to_le32( 2640 - (u32)PCI_FUNC(nesdev->pcidev->devfn) << NES_QPCONTEXT_MISC2_SRC_IP_SHIFT); 2446 + (u32)PCI_FUNC(nesdev->pcidev->devfn) << 2447 + NES_QPCONTEXT_MISC2_SRC_IP_SHIFT); 2641 2448 2642 - nesqp->nesqp_context->arp_index_vlan |= cpu_to_le32( 2643 - nes_arp_table(nesdev, le32_to_cpu(nesqp->nesqp_context->ip0), NULL, 2449 + nesqp->nesqp_context->arp_index_vlan |= 2450 + cpu_to_le32(nes_arp_table(nesdev, 2451 + le32_to_cpu(nesqp->nesqp_context->ip0), NULL, 2644 2452 NES_ARP_RESOLVE) << 16); 2645 2453 2646 2454 nesqp->nesqp_context->ts_val_delta = cpu_to_le32( 2647 - jiffies - nes_read_indexed(nesdev, NES_IDX_TCP_NOW)); 2455 + jiffies - nes_read_indexed(nesdev, NES_IDX_TCP_NOW)); 2648 2456 2649 2457 nesqp->nesqp_context->ird_index = cpu_to_le32(nesqp->hwqp.qp_id); 2650 2458 2651 2459 nesqp->nesqp_context->ird_ord_sizes |= cpu_to_le32( 2652 - ((u32)1 << NES_QPCONTEXT_ORDIRD_IWARP_MODE_SHIFT)); 2653 - nesqp->nesqp_context->ird_ord_sizes |= cpu_to_le32((u32)conn_param->ord); 2460 + ((u32)1 << NES_QPCONTEXT_ORDIRD_IWARP_MODE_SHIFT)); 2461 + nesqp->nesqp_context->ird_ord_sizes |= 2462 + cpu_to_le32((u32)conn_param->ord); 2654 2463 2655 2464 memset(&nes_quad, 0, sizeof(nes_quad)); 2656 - nes_quad.DstIpAdrIndex = cpu_to_le32((u32)PCI_FUNC(nesdev->pcidev->devfn) << 24); 2657 - nes_quad.SrcIpadr = cm_id->remote_addr.sin_addr.s_addr; 2658 - nes_quad.TcpPorts[0] = cm_id->remote_addr.sin_port; 2659 - nes_quad.TcpPorts[1] = cm_id->local_addr.sin_port; 2465 + nes_quad.DstIpAdrIndex = 2466 + cpu_to_le32((u32)PCI_FUNC(nesdev->pcidev->devfn) << 24); 2467 + if (ipv4_is_loopback(cm_id->remote_addr.sin_addr.s_addr)) 2468 + nes_quad.SrcIpadr = nesvnic->local_ipaddr; 2469 + else 2470 + nes_quad.SrcIpadr = cm_id->remote_addr.sin_addr.s_addr; 2471 + nes_quad.TcpPorts[0] = cm_id->remote_addr.sin_port; 2472 + nes_quad.TcpPorts[1] = cm_id->local_addr.sin_port; 2660 2473 2661 2474 /* Produce hash key */ 2662 2475 crc_value = get_crc_value(&nes_quad); 2663 2476 nesqp->hte_index = cpu_to_be32(crc_value ^ 0xffffffff); 2664 2477 nes_debug(NES_DBG_CM, "HTE Index = 0x%08X, CRC = 0x%08X\n", 2665 - nesqp->hte_index, nesqp->hte_index & adapter->hte_index_mask); 2478 + nesqp->hte_index, nesqp->hte_index & adapter->hte_index_mask); 2666 2479 2667 2480 nesqp->hte_index &= adapter->hte_index_mask; 2668 2481 nesqp->nesqp_context->hte_index = cpu_to_le32(nesqp->hte_index); 2669 2482 2670 2483 cm_node->cm_core->api->accelerated(cm_node->cm_core, cm_node); 2671 2484 2672 - nes_debug(NES_DBG_CM, "QP%u, Destination IP = 0x%08X:0x%04X, local = 0x%08X:0x%04X," 2673 - " rcv_nxt=0x%08X, snd_nxt=0x%08X, mpa + private data length=%zu.\n", 2674 - nesqp->hwqp.qp_id, 2485 + nes_debug(NES_DBG_CM, "QP%u, Destination IP = 0x%08X:0x%04X, local = " 2486 + "0x%08X:0x%04X, rcv_nxt=0x%08X, snd_nxt=0x%08X, mpa + " 2487 + "private data length=%zu.\n", nesqp->hwqp.qp_id, 2675 2488 ntohl(cm_id->remote_addr.sin_addr.s_addr), 2676 2489 ntohs(cm_id->remote_addr.sin_port), 2677 2490 ntohl(cm_id->local_addr.sin_addr.s_addr), 2678 2491 ntohs(cm_id->local_addr.sin_port), 2679 2492 le32_to_cpu(nesqp->nesqp_context->rcv_nxt), 2680 2493 le32_to_cpu(nesqp->nesqp_context->snd_nxt), 2681 - conn_param->private_data_len+sizeof(struct ietf_mpa_frame)); 2494 + conn_param->private_data_len + 2495 + sizeof(struct ietf_mpa_frame)); 2682 2496 2683 2497 attr.qp_state = IB_QPS_RTS; 2684 2498 nes_modify_qp(&nesqp->ibqp, &attr, IB_QP_STATE, NULL); ··· 2715 2489 cm_event.private_data_len = 0; 2716 2490 ret = cm_id->event_handler(cm_id, &cm_event); 2717 2491 if (cm_node->loopbackpartner) { 2718 - cm_node->loopbackpartner->mpa_frame_size = nesqp->private_data_len; 2492 + cm_node->loopbackpartner->mpa_frame_size = 2493 + nesqp->private_data_len; 2719 2494 /* copy entire MPA frame to our cm_node's frame */ 2720 - memcpy(cm_node->loopbackpartner->mpa_frame_buf, nesqp->ietf_frame->priv_data, 2721 - nesqp->private_data_len); 2495 + memcpy(cm_node->loopbackpartner->mpa_frame_buf, 2496 + nesqp->ietf_frame->priv_data, nesqp->private_data_len); 2722 2497 create_event(cm_node->loopbackpartner, NES_CM_EVENT_CONNECTED); 2723 2498 } 2724 2499 if (ret) 2725 - printk("%s[%u] OFA CM event_handler returned, ret=%d\n", 2726 - __func__, __LINE__, ret); 2500 + printk(KERN_ERR "%s[%u] OFA CM event_handler returned, " 2501 + "ret=%d\n", __func__, __LINE__, ret); 2727 2502 2728 2503 return 0; 2729 2504 } ··· 2782 2555 if (!nesdev) 2783 2556 return -EINVAL; 2784 2557 2558 + nes_debug(NES_DBG_CM, "QP%u, current IP = 0x%08X, Destination IP = " 2559 + "0x%08X:0x%04X, local = 0x%08X:0x%04X.\n", nesqp->hwqp.qp_id, 2560 + ntohl(nesvnic->local_ipaddr), 2561 + ntohl(cm_id->remote_addr.sin_addr.s_addr), 2562 + ntohs(cm_id->remote_addr.sin_port), 2563 + ntohl(cm_id->local_addr.sin_addr.s_addr), 2564 + ntohs(cm_id->local_addr.sin_port)); 2565 + 2785 2566 atomic_inc(&cm_connects); 2786 - 2787 - nesqp->ietf_frame = kzalloc(sizeof(struct ietf_mpa_frame) + 2788 - conn_param->private_data_len, GFP_KERNEL); 2789 - if (!nesqp->ietf_frame) 2790 - return -ENOMEM; 2791 - 2792 - /* set qp as having an active connection */ 2793 2567 nesqp->active_conn = 1; 2794 - 2795 - nes_debug(NES_DBG_CM, "QP%u, Destination IP = 0x%08X:0x%04X, local = 0x%08X:0x%04X.\n", 2796 - nesqp->hwqp.qp_id, 2797 - ntohl(cm_id->remote_addr.sin_addr.s_addr), 2798 - ntohs(cm_id->remote_addr.sin_port), 2799 - ntohl(cm_id->local_addr.sin_addr.s_addr), 2800 - ntohs(cm_id->local_addr.sin_port)); 2801 2568 2802 2569 /* cache the cm_id in the qp */ 2803 2570 nesqp->cm_id = cm_id; 2804 2571 2805 2572 cm_id->provider_data = nesqp; 2806 2573 2807 - /* copy the private data */ 2808 - if (conn_param->private_data_len) { 2809 - memcpy(nesqp->ietf_frame->priv_data, conn_param->private_data, 2810 - conn_param->private_data_len); 2811 - } 2812 - 2813 2574 nesqp->private_data_len = conn_param->private_data_len; 2814 2575 nesqp->nesqp_context->ird_ord_sizes |= cpu_to_le32((u32)conn_param->ord); 2815 2576 nes_debug(NES_DBG_CM, "requested ord = 0x%08X.\n", (u32)conn_param->ord); 2816 - nes_debug(NES_DBG_CM, "mpa private data len =%u\n", conn_param->private_data_len); 2577 + nes_debug(NES_DBG_CM, "mpa private data len =%u\n", 2578 + conn_param->private_data_len); 2817 2579 2818 - strcpy(&nesqp->ietf_frame->key[0], IEFT_MPA_KEY_REQ); 2819 - nesqp->ietf_frame->flags = IETF_MPA_FLAGS_CRC; 2820 - nesqp->ietf_frame->rev = IETF_MPA_VERSION; 2821 - nesqp->ietf_frame->priv_data_len = htons(conn_param->private_data_len); 2822 - 2823 - if (cm_id->local_addr.sin_addr.s_addr != cm_id->remote_addr.sin_addr.s_addr) 2580 + if (cm_id->local_addr.sin_addr.s_addr != 2581 + cm_id->remote_addr.sin_addr.s_addr) 2824 2582 nes_manage_apbvt(nesvnic, ntohs(cm_id->local_addr.sin_port), 2825 - PCI_FUNC(nesdev->pcidev->devfn), NES_MANAGE_APBVT_ADD); 2583 + PCI_FUNC(nesdev->pcidev->devfn), NES_MANAGE_APBVT_ADD); 2826 2584 2827 2585 /* set up the connection params for the node */ 2828 - cm_info.loc_addr = (cm_id->local_addr.sin_addr.s_addr); 2829 - cm_info.loc_port = (cm_id->local_addr.sin_port); 2830 - cm_info.rem_addr = (cm_id->remote_addr.sin_addr.s_addr); 2831 - cm_info.rem_port = (cm_id->remote_addr.sin_port); 2586 + cm_info.loc_addr = htonl(cm_id->local_addr.sin_addr.s_addr); 2587 + cm_info.loc_port = htons(cm_id->local_addr.sin_port); 2588 + cm_info.rem_addr = htonl(cm_id->remote_addr.sin_addr.s_addr); 2589 + cm_info.rem_port = htons(cm_id->remote_addr.sin_port); 2832 2590 cm_info.cm_id = cm_id; 2833 2591 cm_info.conn_type = NES_CM_IWARP_CONN_TYPE; 2834 2592 2835 2593 cm_id->add_ref(cm_id); 2836 - nes_add_ref(&nesqp->ibqp); 2837 2594 2838 2595 /* create a connect CM node connection */ 2839 - cm_node = g_cm_core->api->connect(g_cm_core, nesvnic, nesqp->ietf_frame, &cm_info); 2596 + cm_node = g_cm_core->api->connect(g_cm_core, nesvnic, 2597 + conn_param->private_data_len, (void *)conn_param->private_data, 2598 + &cm_info); 2840 2599 if (!cm_node) { 2841 - if (cm_id->local_addr.sin_addr.s_addr != cm_id->remote_addr.sin_addr.s_addr) 2600 + if (cm_id->local_addr.sin_addr.s_addr != 2601 + cm_id->remote_addr.sin_addr.s_addr) 2842 2602 nes_manage_apbvt(nesvnic, ntohs(cm_id->local_addr.sin_port), 2843 - PCI_FUNC(nesdev->pcidev->devfn), NES_MANAGE_APBVT_DEL); 2844 - nes_rem_ref(&nesqp->ibqp); 2845 - kfree(nesqp->ietf_frame); 2846 - nesqp->ietf_frame = NULL; 2603 + PCI_FUNC(nesdev->pcidev->devfn), 2604 + NES_MANAGE_APBVT_DEL); 2605 + 2847 2606 cm_id->rem_ref(cm_id); 2848 2607 return -ENOMEM; 2849 2608 } 2850 2609 2851 2610 cm_node->apbvt_set = 1; 2852 2611 nesqp->cm_node = cm_node; 2612 + cm_node->nesqp = nesqp; 2853 2613 2854 2614 return 0; 2855 2615 } ··· 2878 2664 2879 2665 cm_node = g_cm_core->api->listen(g_cm_core, nesvnic, &cm_info); 2880 2666 if (!cm_node) { 2881 - printk("%s[%u] Error returned from listen API call\n", 2667 + printk(KERN_ERR "%s[%u] Error returned from listen API call\n", 2882 2668 __func__, __LINE__); 2883 2669 return -ENOMEM; 2884 2670 } ··· 2886 2672 cm_id->provider_data = cm_node; 2887 2673 2888 2674 if (!cm_node->reused_node) { 2889 - err = nes_manage_apbvt(nesvnic, ntohs(cm_id->local_addr.sin_port), 2890 - PCI_FUNC(nesvnic->nesdev->pcidev->devfn), NES_MANAGE_APBVT_ADD); 2675 + err = nes_manage_apbvt(nesvnic, 2676 + ntohs(cm_id->local_addr.sin_port), 2677 + PCI_FUNC(nesvnic->nesdev->pcidev->devfn), 2678 + NES_MANAGE_APBVT_ADD); 2891 2679 if (err) { 2892 - printk("nes_manage_apbvt call returned %d.\n", err); 2680 + printk(KERN_ERR "nes_manage_apbvt call returned %d.\n", 2681 + err); 2893 2682 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node); 2894 2683 return err; 2895 2684 } ··· 3012 2795 nes_cm_init_tsa_conn(nesqp, cm_node); 3013 2796 3014 2797 /* set the QP tsa context */ 3015 - nesqp->nesqp_context->tcpPorts[0] = cpu_to_le16(ntohs(cm_id->local_addr.sin_port)); 3016 - nesqp->nesqp_context->tcpPorts[1] = cpu_to_le16(ntohs(cm_id->remote_addr.sin_port)); 3017 - nesqp->nesqp_context->ip0 = cpu_to_le32(ntohl(cm_id->remote_addr.sin_addr.s_addr)); 2798 + nesqp->nesqp_context->tcpPorts[0] = 2799 + cpu_to_le16(ntohs(cm_id->local_addr.sin_port)); 2800 + nesqp->nesqp_context->tcpPorts[1] = 2801 + cpu_to_le16(ntohs(cm_id->remote_addr.sin_port)); 2802 + if (ipv4_is_loopback(cm_id->remote_addr.sin_addr.s_addr)) 2803 + nesqp->nesqp_context->ip0 = 2804 + cpu_to_le32(ntohl(nesvnic->local_ipaddr)); 2805 + else 2806 + nesqp->nesqp_context->ip0 = 2807 + cpu_to_le32(ntohl(cm_id->remote_addr.sin_addr.s_addr)); 3018 2808 3019 2809 nesqp->nesqp_context->misc2 |= cpu_to_le32( 3020 - (u32)PCI_FUNC(nesdev->pcidev->devfn) << NES_QPCONTEXT_MISC2_SRC_IP_SHIFT); 2810 + (u32)PCI_FUNC(nesdev->pcidev->devfn) << 2811 + NES_QPCONTEXT_MISC2_SRC_IP_SHIFT); 3021 2812 nesqp->nesqp_context->arp_index_vlan |= cpu_to_le32( 3022 - nes_arp_table(nesdev, le32_to_cpu(nesqp->nesqp_context->ip0), 2813 + nes_arp_table(nesdev, 2814 + le32_to_cpu(nesqp->nesqp_context->ip0), 3023 2815 NULL, NES_ARP_RESOLVE) << 16); 3024 2816 nesqp->nesqp_context->ts_val_delta = cpu_to_le32( 3025 2817 jiffies - nes_read_indexed(nesdev, NES_IDX_TCP_NOW)); 3026 2818 nesqp->nesqp_context->ird_index = cpu_to_le32(nesqp->hwqp.qp_id); 3027 2819 nesqp->nesqp_context->ird_ord_sizes |= 3028 - cpu_to_le32((u32)1 << NES_QPCONTEXT_ORDIRD_IWARP_MODE_SHIFT); 2820 + cpu_to_le32((u32)1 << 2821 + NES_QPCONTEXT_ORDIRD_IWARP_MODE_SHIFT); 3029 2822 3030 2823 /* Adjust tail for not having a LSMM */ 3031 2824 nesqp->hwqp.sq_tail = 1; 3032 2825 3033 2826 #if defined(NES_SEND_FIRST_WRITE) 3034 - if (cm_node->send_write0) { 3035 - nes_debug(NES_DBG_CM, "Sending first write.\n"); 3036 - wqe = &nesqp->hwqp.sq_vbase[0]; 3037 - u64temp = (unsigned long)nesqp; 3038 - u64temp |= NES_SW_CONTEXT_ALIGN>>1; 3039 - set_wqe_64bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_COMP_CTX_LOW_IDX, 3040 - u64temp); 3041 - wqe->wqe_words[NES_IWARP_SQ_WQE_MISC_IDX] = cpu_to_le32(NES_IWARP_SQ_OP_RDMAW); 3042 - wqe->wqe_words[NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX] = 0; 3043 - wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_LOW_IDX] = 0; 3044 - wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_HIGH_IDX] = 0; 3045 - wqe->wqe_words[NES_IWARP_SQ_WQE_LENGTH0_IDX] = 0; 3046 - wqe->wqe_words[NES_IWARP_SQ_WQE_STAG0_IDX] = 0; 2827 + if (cm_node->send_write0) { 2828 + nes_debug(NES_DBG_CM, "Sending first write.\n"); 2829 + wqe = &nesqp->hwqp.sq_vbase[0]; 2830 + u64temp = (unsigned long)nesqp; 2831 + u64temp |= NES_SW_CONTEXT_ALIGN>>1; 2832 + set_wqe_64bit_value(wqe->wqe_words, 2833 + NES_IWARP_SQ_WQE_COMP_CTX_LOW_IDX, u64temp); 2834 + wqe->wqe_words[NES_IWARP_SQ_WQE_MISC_IDX] = 2835 + cpu_to_le32(NES_IWARP_SQ_OP_RDMAW); 2836 + wqe->wqe_words[NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX] = 0; 2837 + wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_LOW_IDX] = 0; 2838 + wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_HIGH_IDX] = 0; 2839 + wqe->wqe_words[NES_IWARP_SQ_WQE_LENGTH0_IDX] = 0; 2840 + wqe->wqe_words[NES_IWARP_SQ_WQE_STAG0_IDX] = 0; 3047 2841 3048 - /* use the reserved spot on the WQ for the extra first WQE */ 3049 - nesqp->nesqp_context->ird_ord_sizes &= cpu_to_le32(~(NES_QPCONTEXT_ORDIRD_LSMM_PRESENT | 3050 - NES_QPCONTEXT_ORDIRD_WRPDU | NES_QPCONTEXT_ORDIRD_ALSMM)); 3051 - nesqp->skip_lsmm = 1; 3052 - nesqp->hwqp.sq_tail = 0; 3053 - nes_write32(nesdev->regs + NES_WQE_ALLOC, 3054 - (1 << 24) | 0x00800000 | nesqp->hwqp.qp_id); 3055 - } 2842 + /* use the reserved spot on the WQ for the extra first WQE */ 2843 + nesqp->nesqp_context->ird_ord_sizes &= 2844 + cpu_to_le32(~(NES_QPCONTEXT_ORDIRD_LSMM_PRESENT | 2845 + NES_QPCONTEXT_ORDIRD_WRPDU | 2846 + NES_QPCONTEXT_ORDIRD_ALSMM)); 2847 + nesqp->skip_lsmm = 1; 2848 + nesqp->hwqp.sq_tail = 0; 2849 + nes_write32(nesdev->regs + NES_WQE_ALLOC, 2850 + (1 << 24) | 0x00800000 | nesqp->hwqp.qp_id); 2851 + } 3056 2852 #endif 3057 2853 3058 2854 memset(&nes_quad, 0, sizeof(nes_quad)); 3059 2855 3060 - nes_quad.DstIpAdrIndex = cpu_to_le32((u32)PCI_FUNC(nesdev->pcidev->devfn) << 24); 3061 - nes_quad.SrcIpadr = cm_id->remote_addr.sin_addr.s_addr; 2856 + nes_quad.DstIpAdrIndex = 2857 + cpu_to_le32((u32)PCI_FUNC(nesdev->pcidev->devfn) << 24); 2858 + if (ipv4_is_loopback(cm_id->remote_addr.sin_addr.s_addr)) 2859 + nes_quad.SrcIpadr = nesvnic->local_ipaddr; 2860 + else 2861 + nes_quad.SrcIpadr = cm_id->remote_addr.sin_addr.s_addr; 3062 2862 nes_quad.TcpPorts[0] = cm_id->remote_addr.sin_port; 3063 2863 nes_quad.TcpPorts[1] = cm_id->local_addr.sin_port; 3064 2864 ··· 3092 2858 nesqp->private_data_len = (u8) cm_node->mpa_frame_size; 3093 2859 cm_node->cm_core->api->accelerated(cm_node->cm_core, cm_node); 3094 2860 3095 - /* modify QP state to rts */ 3096 - attr.qp_state = IB_QPS_RTS; 3097 - nes_modify_qp(&nesqp->ibqp, &attr, IB_QP_STATE, NULL); 3098 - 3099 2861 /* notify OF layer we successfully created the requested connection */ 3100 2862 cm_event.event = IW_CM_EVENT_CONNECT_REPLY; 3101 2863 cm_event.status = IW_CM_EVENT_STATUS_ACCEPTED; ··· 3100 2870 cm_event.local_addr.sin_port = cm_id->local_addr.sin_port; 3101 2871 cm_event.remote_addr = cm_id->remote_addr; 3102 2872 3103 - cm_event.private_data = (void *)event->cm_node->mpa_frame_buf; 3104 - cm_event.private_data_len = (u8) event->cm_node->mpa_frame_size; 2873 + cm_event.private_data = (void *)event->cm_node->mpa_frame_buf; 2874 + cm_event.private_data_len = (u8) event->cm_node->mpa_frame_size; 3105 2875 3106 2876 cm_event.local_addr.sin_addr.s_addr = event->cm_info.rem_addr; 3107 2877 ret = cm_id->event_handler(cm_id, &cm_event); 3108 2878 nes_debug(NES_DBG_CM, "OFA CM event_handler returned, ret=%d\n", ret); 3109 2879 3110 2880 if (ret) 3111 - printk("%s[%u] OFA CM event_handler returned, ret=%d\n", 3112 - __func__, __LINE__, ret); 3113 - nes_debug(NES_DBG_CM, "Exiting connect thread for QP%u. jiffies = %lu\n", 3114 - nesqp->hwqp.qp_id, jiffies ); 2881 + printk(KERN_ERR "%s[%u] OFA CM event_handler returned, " 2882 + "ret=%d\n", __func__, __LINE__, ret); 2883 + attr.qp_state = IB_QPS_RTS; 2884 + nes_modify_qp(&nesqp->ibqp, &attr, IB_QP_STATE, NULL); 3115 2885 3116 - nes_rem_ref(&nesqp->ibqp); 2886 + nes_debug(NES_DBG_CM, "Exiting connect thread for QP%u. jiffies = " 2887 + "%lu\n", nesqp->hwqp.qp_id, jiffies); 3117 2888 3118 2889 return; 3119 2890 } ··· 3158 2927 cm_event.private_data = NULL; 3159 2928 cm_event.private_data_len = 0; 3160 2929 3161 - nes_debug(NES_DBG_CM, "call CM_EVENT REJECTED, local_addr=%08x, remove_addr=%08x\n", 3162 - cm_event.local_addr.sin_addr.s_addr, cm_event.remote_addr.sin_addr.s_addr); 2930 + nes_debug(NES_DBG_CM, "call CM_EVENT REJECTED, local_addr=%08x, " 2931 + "remove_addr=%08x\n", cm_event.local_addr.sin_addr.s_addr, 2932 + cm_event.remote_addr.sin_addr.s_addr); 3163 2933 3164 2934 ret = cm_id->event_handler(cm_id, &cm_event); 3165 2935 nes_debug(NES_DBG_CM, "OFA CM event_handler returned, ret=%d\n", ret); 3166 2936 if (ret) 3167 - printk("%s[%u] OFA CM event_handler returned, ret=%d\n", 3168 - __func__, __LINE__, ret); 2937 + printk(KERN_ERR "%s[%u] OFA CM event_handler returned, " 2938 + "ret=%d\n", __func__, __LINE__, ret); 3169 2939 nes_rem_ref(&nesqp->ibqp); 3170 - cm_id->rem_ref(cm_id); 2940 + cm_id->rem_ref(cm_id); 3171 2941 2942 + rem_ref_cm_node(event->cm_node->cm_core, event->cm_node); 3172 2943 return; 3173 2944 } 3174 2945 ··· 3273 3040 add_ref_cm_node(event->cm_node); 3274 3041 event->cm_info.cm_id->add_ref(event->cm_info.cm_id); 3275 3042 INIT_WORK(&event->event_work, nes_cm_event_handler); 3276 - nes_debug(NES_DBG_CM, "queue_work, event=%p\n", event); 3043 + nes_debug(NES_DBG_CM, "cm_node=%p queue_work, event=%p\n", 3044 + event->cm_node, event); 3277 3045 3278 3046 queue_work(event->cm_node->cm_core->event_wq, &event->event_work); 3279 3047 ··· 3290 3056 */ 3291 3057 static void nes_cm_event_handler(struct work_struct *work) 3292 3058 { 3293 - struct nes_cm_event *event = container_of(work, struct nes_cm_event, event_work); 3059 + struct nes_cm_event *event = container_of(work, struct nes_cm_event, 3060 + event_work); 3294 3061 struct nes_cm_core *cm_core; 3295 3062 3296 - if ((!event) || (!event->cm_node) || (!event->cm_node->cm_core)) { 3063 + if ((!event) || (!event->cm_node) || (!event->cm_node->cm_core)) 3297 3064 return; 3298 - } 3065 + 3299 3066 cm_core = event->cm_node->cm_core; 3300 3067 nes_debug(NES_DBG_CM, "event=%p, event->type=%u, events posted=%u\n", 3301 - event, event->type, atomic_read(&cm_core->events_posted)); 3068 + event, event->type, atomic_read(&cm_core->events_posted)); 3302 3069 3303 3070 switch (event->type) { 3304 - case NES_CM_EVENT_MPA_REQ: 3305 - cm_event_mpa_req(event); 3306 - nes_debug(NES_DBG_CM, "CM Event: MPA REQUEST\n"); 3071 + case NES_CM_EVENT_MPA_REQ: 3072 + cm_event_mpa_req(event); 3073 + nes_debug(NES_DBG_CM, "cm_node=%p CM Event: MPA REQUEST\n", 3074 + event->cm_node); 3075 + break; 3076 + case NES_CM_EVENT_RESET: 3077 + nes_debug(NES_DBG_CM, "cm_node = %p CM Event: RESET\n", 3078 + event->cm_node); 3079 + cm_event_reset(event); 3080 + break; 3081 + case NES_CM_EVENT_CONNECTED: 3082 + if ((!event->cm_node->cm_id) || 3083 + (event->cm_node->state != NES_CM_STATE_TSA)) 3307 3084 break; 3308 - case NES_CM_EVENT_RESET: 3309 - nes_debug(NES_DBG_CM, "CM Event: RESET\n"); 3310 - cm_event_reset(event); 3085 + cm_event_connected(event); 3086 + nes_debug(NES_DBG_CM, "CM Event: CONNECTED\n"); 3087 + break; 3088 + case NES_CM_EVENT_ABORTED: 3089 + if ((!event->cm_node->cm_id) || 3090 + (event->cm_node->state == NES_CM_STATE_TSA)) 3311 3091 break; 3312 - case NES_CM_EVENT_CONNECTED: 3313 - if ((!event->cm_node->cm_id) || 3314 - (event->cm_node->state != NES_CM_STATE_TSA)) { 3315 - break; 3316 - } 3317 - cm_event_connected(event); 3318 - nes_debug(NES_DBG_CM, "CM Event: CONNECTED\n"); 3319 - break; 3320 - case NES_CM_EVENT_ABORTED: 3321 - if ((!event->cm_node->cm_id) || (event->cm_node->state == NES_CM_STATE_TSA)) { 3322 - break; 3323 - } 3324 - cm_event_connect_error(event); 3325 - nes_debug(NES_DBG_CM, "CM Event: ABORTED\n"); 3326 - break; 3327 - case NES_CM_EVENT_DROPPED_PKT: 3328 - nes_debug(NES_DBG_CM, "CM Event: DROPPED PKT\n"); 3329 - break; 3330 - default: 3331 - nes_debug(NES_DBG_CM, "CM Event: UNKNOWN EVENT TYPE\n"); 3332 - break; 3092 + cm_event_connect_error(event); 3093 + nes_debug(NES_DBG_CM, "CM Event: ABORTED\n"); 3094 + break; 3095 + case NES_CM_EVENT_DROPPED_PKT: 3096 + nes_debug(NES_DBG_CM, "CM Event: DROPPED PKT\n"); 3097 + break; 3098 + default: 3099 + nes_debug(NES_DBG_CM, "CM Event: UNKNOWN EVENT TYPE\n"); 3100 + break; 3333 3101 } 3334 3102 3335 3103 atomic_dec(&cm_core->events_posted);
+20 -3
drivers/infiniband/hw/nes/nes_cm.h
··· 83 83 #define SET_FIN 4 84 84 #define SET_RST 8 85 85 86 + #define TCP_OPTIONS_PADDING 3 87 + 86 88 struct option_base { 87 89 u8 optionnum; 88 90 u8 length; ··· 179 177 NES_CM_STATE_ESTABLISHED, 180 178 NES_CM_STATE_ACCEPTING, 181 179 NES_CM_STATE_MPAREQ_SENT, 180 + NES_CM_STATE_MPAREQ_RCVD, 182 181 NES_CM_STATE_TSA, 183 182 NES_CM_STATE_FIN_WAIT1, 184 183 NES_CM_STATE_FIN_WAIT2, ··· 189 186 NES_CM_STATE_CLOSING, 190 187 NES_CM_STATE_CLOSED 191 188 }; 189 + 190 + enum nes_tcpip_pkt_type { 191 + NES_PKT_TYPE_UNKNOWN, 192 + NES_PKT_TYPE_SYN, 193 + NES_PKT_TYPE_SYNACK, 194 + NES_PKT_TYPE_ACK, 195 + NES_PKT_TYPE_FIN, 196 + NES_PKT_TYPE_RST 197 + }; 198 + 192 199 193 200 /* type of nes connection */ 194 201 enum nes_cm_conn_type { ··· 270 257 struct net_device *netdev; 271 258 272 259 struct nes_cm_node *loopbackpartner; 273 - struct list_head retrans_list; 260 + 261 + struct nes_timer_entry *send_entry; 262 + 274 263 spinlock_t retrans_list_lock; 275 264 struct list_head recv_list; 276 265 spinlock_t recv_list_lock; ··· 291 276 struct nes_vnic *nesvnic; 292 277 int apbvt_set; 293 278 int accept_pend; 279 + int freed; 280 + struct nes_qp *nesqp; 294 281 }; 295 282 296 283 /* structure for client or CM to fill when making CM api calls. */ ··· 383 366 struct nes_cm_info *); 384 367 int (*stop_listener)(struct nes_cm_core *, struct nes_cm_listener *); 385 368 struct nes_cm_node * (*connect)(struct nes_cm_core *, 386 - struct nes_vnic *, struct ietf_mpa_frame *, 369 + struct nes_vnic *, u16, void *, 387 370 struct nes_cm_info *); 388 371 int (*close)(struct nes_cm_core *, struct nes_cm_node *); 389 372 int (*accept)(struct nes_cm_core *, struct ietf_mpa_frame *, 390 373 struct nes_cm_node *); 391 374 int (*reject)(struct nes_cm_core *, struct ietf_mpa_frame *, 392 375 struct nes_cm_node *); 393 - int (*recv_pkt)(struct nes_cm_core *, struct nes_vnic *, 376 + void (*recv_pkt)(struct nes_cm_core *, struct nes_vnic *, 394 377 struct sk_buff *); 395 378 int (*destroy_cm_core)(struct nes_cm_core *); 396 379 int (*get)(struct nes_cm_core *);
-9
drivers/infiniband/hw/nes/nes_hw.c
··· 2814 2814 nesqp = *((struct nes_qp **)&context); 2815 2815 if (atomic_inc_return(&nesqp->close_timer_started) == 1) { 2816 2816 nesqp->cm_id->add_ref(nesqp->cm_id); 2817 - nes_add_ref(&nesqp->ibqp); 2818 2817 schedule_nes_timer(nesqp->cm_node, (struct sk_buff *)nesqp, 2819 2818 NES_TIMER_TYPE_CLOSE, 1, 0); 2820 2819 nes_debug(NES_DBG_AEQ, "QP%u Not decrementing QP refcount (%d)," ··· 2837 2838 if (async_event_id == NES_AEQE_AEID_RESET_SENT) { 2838 2839 tcp_state = NES_AEQE_TCP_STATE_CLOSED; 2839 2840 } 2840 - nes_add_ref(&nesqp->ibqp); 2841 2841 spin_lock_irqsave(&nesqp->lock, flags); 2842 2842 nesqp->hw_iwarp_state = iwarp_state; 2843 2843 nesqp->hw_tcp_state = tcp_state; ··· 2874 2876 } 2875 2877 spin_unlock_irqrestore(&nesqp->lock, flags); 2876 2878 if (next_iwarp_state) { 2877 - nes_add_ref(&nesqp->ibqp); 2878 2879 nes_debug(NES_DBG_AEQ, "issuing hw modifyqp for QP%u. next state = 0x%08X," 2879 2880 " also added another reference\n", 2880 2881 nesqp->hwqp.qp_id, next_iwarp_state); ··· 2885 2888 /* FIN Received but ib state not RTS, 2886 2889 close complete will be on its way */ 2887 2890 spin_unlock_irqrestore(&nesqp->lock, flags); 2888 - nes_rem_ref(&nesqp->ibqp); 2889 2891 return; 2890 2892 } 2891 2893 spin_unlock_irqrestore(&nesqp->lock, flags); ··· 2918 2922 if ((tcp_state == NES_AEQE_TCP_STATE_CLOSE_WAIT) || 2919 2923 ((nesqp->ibqp_state == IB_QPS_RTS)&& 2920 2924 (async_event_id == NES_AEQE_AEID_LLP_CONNECTION_RESET))) { 2921 - nes_add_ref(&nesqp->ibqp); 2922 2925 nes_cm_disconn(nesqp); 2923 2926 } else { 2924 2927 nesqp->in_disconnect = 0; ··· 2926 2931 break; 2927 2932 case NES_AEQE_AEID_LLP_TOO_MANY_RETRIES: 2928 2933 nesqp = *((struct nes_qp **)&context); 2929 - nes_add_ref(&nesqp->ibqp); 2930 2934 spin_lock_irqsave(&nesqp->lock, flags); 2931 2935 nesqp->hw_iwarp_state = NES_AEQE_IWARP_STATE_ERROR; 2932 2936 nesqp->hw_tcp_state = NES_AEQE_TCP_STATE_CLOSED; ··· 3036 3042 nesqp->ibqp.event_handler(&ibevent, nesqp->ibqp.qp_context); 3037 3043 } 3038 3044 /* tell cm to disconnect, cm will queue work to thread */ 3039 - nes_add_ref(&nesqp->ibqp); 3040 3045 nes_cm_disconn(nesqp); 3041 3046 break; 3042 3047 case NES_AEQE_AEID_DDP_UBE_INVALID_MSN_NO_BUFFER_AVAILABLE: ··· 3055 3062 nesqp->ibqp.event_handler(&ibevent, nesqp->ibqp.qp_context); 3056 3063 } 3057 3064 /* tell cm to disconnect, cm will queue work to thread */ 3058 - nes_add_ref(&nesqp->ibqp); 3059 3065 nes_cm_disconn(nesqp); 3060 3066 break; 3061 3067 case NES_AEQE_AEID_LLP_RECEIVED_MPA_CRC_ERROR: ··· 3074 3082 nesqp->ibqp.event_handler(&ibevent, nesqp->ibqp.qp_context); 3075 3083 } 3076 3084 /* tell cm to disconnect, cm will queue work to thread */ 3077 - nes_add_ref(&nesqp->ibqp); 3078 3085 nes_cm_disconn(nesqp); 3079 3086 break; 3080 3087 /* TODO: additional AEs need to be here */
-15
drivers/infiniband/hw/nes/nes_verbs.c
··· 2867 2867 nesqp->hwqp.qp_id, attr->qp_state, nesqp->ibqp_state, 2868 2868 nesqp->iwarp_state, atomic_read(&nesqp->refcount)); 2869 2869 2870 - nes_add_ref(&nesqp->ibqp); 2871 2870 spin_lock_irqsave(&nesqp->lock, qplockflags); 2872 2871 2873 2872 nes_debug(NES_DBG_MOD_QP, "QP%u: hw_iwarp_state=0x%X, hw_tcp_state=0x%X," ··· 2881 2882 nesqp->hwqp.qp_id); 2882 2883 if (nesqp->iwarp_state > (u32)NES_CQP_QP_IWARP_STATE_IDLE) { 2883 2884 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 2884 - nes_rem_ref(&nesqp->ibqp); 2885 2885 return -EINVAL; 2886 2886 } 2887 2887 next_iwarp_state = NES_CQP_QP_IWARP_STATE_IDLE; ··· 2891 2893 nesqp->hwqp.qp_id); 2892 2894 if (nesqp->iwarp_state>(u32)NES_CQP_QP_IWARP_STATE_IDLE) { 2893 2895 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 2894 - nes_rem_ref(&nesqp->ibqp); 2895 2896 return -EINVAL; 2896 2897 } 2897 2898 next_iwarp_state = NES_CQP_QP_IWARP_STATE_IDLE; ··· 2901 2904 nesqp->hwqp.qp_id); 2902 2905 if (nesqp->iwarp_state>(u32)NES_CQP_QP_IWARP_STATE_RTS) { 2903 2906 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 2904 - nes_rem_ref(&nesqp->ibqp); 2905 2907 return -EINVAL; 2906 2908 } 2907 2909 if (nesqp->cm_id == NULL) { 2908 2910 nes_debug(NES_DBG_MOD_QP, "QP%u: Failing attempt to move QP to RTS without a CM_ID. \n", 2909 2911 nesqp->hwqp.qp_id ); 2910 2912 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 2911 - nes_rem_ref(&nesqp->ibqp); 2912 2913 return -EINVAL; 2913 2914 } 2914 2915 next_iwarp_state = NES_CQP_QP_IWARP_STATE_RTS; ··· 2924 2929 nesqp->hwqp.qp_id, nesqp->hwqp.sq_head, nesqp->hwqp.sq_tail); 2925 2930 if (nesqp->iwarp_state == (u32)NES_CQP_QP_IWARP_STATE_CLOSING) { 2926 2931 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 2927 - nes_rem_ref(&nesqp->ibqp); 2928 2932 return 0; 2929 2933 } else { 2930 2934 if (nesqp->iwarp_state > (u32)NES_CQP_QP_IWARP_STATE_CLOSING) { ··· 2931 2937 " ignored due to current iWARP state\n", 2932 2938 nesqp->hwqp.qp_id); 2933 2939 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 2934 - nes_rem_ref(&nesqp->ibqp); 2935 2940 return -EINVAL; 2936 2941 } 2937 2942 if (nesqp->hw_iwarp_state != NES_AEQE_IWARP_STATE_RTS) { ··· 2962 2969 nesqp->hwqp.qp_id); 2963 2970 if (nesqp->iwarp_state>=(u32)NES_CQP_QP_IWARP_STATE_TERMINATE) { 2964 2971 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 2965 - nes_rem_ref(&nesqp->ibqp); 2966 2972 return -EINVAL; 2967 2973 } 2968 2974 /* next_iwarp_state = (NES_CQP_QP_IWARP_STATE_TERMINATE | 0x02000000); */ ··· 2974 2982 case IB_QPS_RESET: 2975 2983 if (nesqp->iwarp_state == (u32)NES_CQP_QP_IWARP_STATE_ERROR) { 2976 2984 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 2977 - nes_rem_ref(&nesqp->ibqp); 2978 2985 return -EINVAL; 2979 2986 } 2980 2987 nes_debug(NES_DBG_MOD_QP, "QP%u: new state = error\n", ··· 2999 3008 break; 3000 3009 default: 3001 3010 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 3002 - nes_rem_ref(&nesqp->ibqp); 3003 3011 return -EINVAL; 3004 3012 break; 3005 3013 } ··· 3078 3088 nesqp->hwqp.qp_id, atomic_read(&nesqp->refcount), 3079 3089 original_last_aeq, nesqp->last_aeq); 3080 3090 /* this one is for the cm_disconnect thread */ 3081 - nes_add_ref(&nesqp->ibqp); 3082 3091 spin_lock_irqsave(&nesqp->lock, qplockflags); 3083 3092 nesqp->hw_tcp_state = NES_AEQE_TCP_STATE_CLOSED; 3084 3093 nesqp->last_aeq = NES_AEQE_AEID_RESET_SENT; ··· 3086 3097 } else { 3087 3098 nes_debug(NES_DBG_MOD_QP, "QP%u No fake disconnect, QP refcount=%d\n", 3088 3099 nesqp->hwqp.qp_id, atomic_read(&nesqp->refcount)); 3089 - nes_rem_ref(&nesqp->ibqp); 3090 3100 } 3091 3101 } else { 3092 3102 spin_lock_irqsave(&nesqp->lock, qplockflags); 3093 3103 if (nesqp->cm_id) { 3094 3104 /* These two are for the timer thread */ 3095 3105 if (atomic_inc_return(&nesqp->close_timer_started) == 1) { 3096 - nes_add_ref(&nesqp->ibqp); 3097 3106 nesqp->cm_id->add_ref(nesqp->cm_id); 3098 3107 nes_debug(NES_DBG_MOD_QP, "QP%u Not decrementing QP refcount (%d)," 3099 3108 " need ae to finish up, original_last_aeq = 0x%04X." ··· 3115 3128 " original_last_aeq = 0x%04X. last_aeq = 0x%04X.\n", 3116 3129 nesqp->hwqp.qp_id, atomic_read(&nesqp->refcount), 3117 3130 original_last_aeq, nesqp->last_aeq); 3118 - nes_rem_ref(&nesqp->ibqp); 3119 3131 } 3120 3132 } else { 3121 3133 nes_debug(NES_DBG_MOD_QP, "QP%u Decrementing QP refcount (%d), No ae to finish up," 3122 3134 " original_last_aeq = 0x%04X. last_aeq = 0x%04X.\n", 3123 3135 nesqp->hwqp.qp_id, atomic_read(&nesqp->refcount), 3124 3136 original_last_aeq, nesqp->last_aeq); 3125 - nes_rem_ref(&nesqp->ibqp); 3126 3137 } 3127 3138 3128 3139 err = 0;
+12 -10
drivers/infiniband/ulp/ipoib/Kconfig
··· 11 11 12 12 config INFINIBAND_IPOIB_CM 13 13 bool "IP-over-InfiniBand Connected Mode support" 14 - depends on INFINIBAND_IPOIB && EXPERIMENTAL 14 + depends on INFINIBAND_IPOIB 15 15 default n 16 16 ---help--- 17 - This option enables experimental support for IPoIB connected mode. 18 - After enabling this option, you need to switch to connected mode through 19 - /sys/class/net/ibXXX/mode to actually create connections, and then increase 20 - the interface MTU with e.g. ifconfig ib0 mtu 65520. 17 + This option enables support for IPoIB connected mode. After 18 + enabling this option, you need to switch to connected mode 19 + through /sys/class/net/ibXXX/mode to actually create 20 + connections, and then increase the interface MTU with 21 + e.g. ifconfig ib0 mtu 65520. 21 22 22 - WARNING: Enabling connected mode will trigger some 23 - packet drops for multicast and UD mode traffic from this interface, 23 + WARNING: Enabling connected mode will trigger some packet 24 + drops for multicast and UD mode traffic from this interface, 24 25 unless you limit mtu for these destinations to 2044. 25 26 26 27 config INFINIBAND_IPOIB_DEBUG ··· 34 33 debug_level and mcast_debug_level module parameters (which 35 34 can also be set after the driver is loaded through sysfs). 36 35 37 - This option also creates an "ipoib_debugfs," which can be 38 - mounted to expose debugging information about IB multicast 39 - groups used by the IPoIB driver. 36 + This option also creates a directory tree under ipoib/ in 37 + debugfs, which contains files that expose debugging 38 + information about IB multicast groups used by the IPoIB 39 + driver. 40 40 41 41 config INFINIBAND_IPOIB_DEBUG_DATA 42 42 bool "IP-over-InfiniBand data path debugging"
+1
drivers/net/mlx4/alloc.c
··· 1 1 /* 2 2 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. 3 + * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. 3 4 * 4 5 * This software is available to you under a choice of one of two 5 6 * licenses. You may choose to be licensed under the terms of the GNU
+1
drivers/net/mlx4/catas.c
··· 1 1 /* 2 2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. 3 + * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. 3 4 * 4 5 * This software is available to you under a choice of one of two 5 6 * licenses. You may choose to be licensed under the terms of the GNU
+1 -1
drivers/net/mlx4/cmd.c
··· 1 1 /* 2 2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 3 - * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 3 + * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. 4 4 * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved. 5 5 * 6 6 * This software is available to you under a choice of one of two
+1 -1
drivers/net/mlx4/cq.c
··· 2 2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 3 3 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 4 4 * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved. 5 - * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 5 + * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. 6 6 * Copyright (c) 2004 Voltaire, Inc. All rights reserved. 7 7 * 8 8 * This software is available to you under a choice of one of two
+1 -1
drivers/net/mlx4/eq.c
··· 1 1 /* 2 - * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 2 + * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. 3 3 * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two
+1 -1
drivers/net/mlx4/fw.c
··· 1 1 /* 2 2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 3 - * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 3 + * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. 4 4 * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved. 5 5 * 6 6 * This software is available to you under a choice of one of two
+1 -1
drivers/net/mlx4/fw.h
··· 1 1 /* 2 2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 3 - * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 3 + * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. 4 4 * Copyright (c) 2006, 2007 Cisco Systems. All rights reserved. 5 5 * 6 6 * This software is available to you under a choice of one of two
+1 -1
drivers/net/mlx4/icm.c
··· 1 1 /* 2 - * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 2 + * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. 3 3 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two
+1 -1
drivers/net/mlx4/icm.h
··· 1 1 /* 2 - * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 2 + * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. 3 3 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two
+1
drivers/net/mlx4/intf.c
··· 1 1 /* 2 2 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. 3 + * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. 3 4 * 4 5 * This software is available to you under a choice of one of two 5 6 * licenses. You may choose to be licensed under the terms of the GNU
+1 -1
drivers/net/mlx4/main.c
··· 1 1 /* 2 2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 3 3 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 4 - * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 4 + * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. 5 5 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. 6 6 * 7 7 * This software is available to you under a choice of one of two
+1
drivers/net/mlx4/mcg.c
··· 1 1 /* 2 2 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. 3 + * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. 3 4 * 4 5 * This software is available to you under a choice of one of two 5 6 * licenses. You may choose to be licensed under the terms of the GNU
+1 -1
drivers/net/mlx4/mlx4.h
··· 2 2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 3 3 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 4 4 * Copyright (c) 2005, 2006, 2007 Cisco Systems. All rights reserved. 5 - * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 5 + * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. 6 6 * Copyright (c) 2004 Voltaire, Inc. All rights reserved. 7 7 * 8 8 * This software is available to you under a choice of one of two
+1 -1
drivers/net/mlx4/mr.c
··· 1 1 /* 2 2 * Copyright (c) 2004 Topspin Communications. All rights reserved. 3 - * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 3 + * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. 4 4 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. 5 5 * 6 6 * This software is available to you under a choice of one of two
+1 -1
drivers/net/mlx4/qp.c
··· 1 1 /* 2 2 * Copyright (c) 2004 Topspin Communications. All rights reserved. 3 3 * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved. 4 - * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 4 + * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. 5 5 * Copyright (c) 2004 Voltaire, Inc. All rights reserved. 6 6 * 7 7 * This software is available to you under a choice of one of two
+1
drivers/net/mlx4/reset.c
··· 1 1 /* 2 2 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. 3 + * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. 3 4 * 4 5 * This software is available to you under a choice of one of two 5 6 * licenses. You may choose to be licensed under the terms of the GNU
+1
drivers/net/mlx4/srq.c
··· 1 1 /* 2 2 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. 3 + * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. 3 4 * 4 5 * This software is available to you under a choice of one of two 5 6 * licenses. You may choose to be licensed under the terms of the GNU
+3 -1
include/linux/mlx4/qp.h
··· 164 164 MLX4_WQE_CTRL_SOLICITED = 1 << 1, 165 165 MLX4_WQE_CTRL_IP_CSUM = 1 << 4, 166 166 MLX4_WQE_CTRL_TCP_UDP_CSUM = 1 << 5, 167 + MLX4_WQE_CTRL_INS_VLAN = 1 << 6, 167 168 }; 168 169 169 170 struct mlx4_wqe_ctrl_seg { 170 171 __be32 owner_opcode; 171 - u8 reserved2[3]; 172 + __be16 vlan_tag; 173 + u8 ins_vlan; 172 174 u8 fence_size; 173 175 /* 174 176 * High 24 bits are SRC remote buffer; low 8 bits are flags: