| 
				
			 | 
			
			
				
				@@ -35,10 +35,6 @@ FILE_LICENCE ( GPL2_OR_LATER ); 
			 | 
		
		
	
		
			
			| 
				35
			 | 
			
				35
			 | 
			
			
				
				  * 
			 | 
		
		
	
		
			
			| 
				36
			 | 
			
				36
			 | 
			
			
				
				  */ 
			 | 
		
		
	
		
			
			| 
				37
			 | 
			
				37
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				38
			 | 
			
				
			 | 
			
			
				
				-/** Ring refill profiler */ 
			 | 
		
		
	
		
			
			| 
				39
			 | 
			
				
			 | 
			
			
				
				-static struct profiler ncm_refill_profiler __profiler = 
			 | 
		
		
	
		
			
			| 
				40
			 | 
			
				
			 | 
			
			
				
				-	{ .name = "ncm.refill" }; 
			 | 
		
		
	
		
			
			| 
				41
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				42
			 | 
			
				38
			 | 
			
			
				
				 /** Interrupt completion profiler */ 
			 | 
		
		
	
		
			
			| 
				43
			 | 
			
				39
			 | 
			
			
				
				 static struct profiler ncm_intr_profiler __profiler = 
			 | 
		
		
	
		
			
			| 
				44
			 | 
			
				40
			 | 
			
			
				
				 	{ .name = "ncm.intr" }; 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -55,144 +51,6 @@ static struct profiler ncm_in_datagram_profiler __profiler = 
			 | 
		
		
	
		
			
			| 
				55
			 | 
			
				51
			 | 
			
			
				
				 static struct profiler ncm_out_profiler __profiler = 
			 | 
		
		
	
		
			
			| 
				56
			 | 
			
				52
			 | 
			
			
				
				 	{ .name = "ncm.out" }; 
			 | 
		
		
	
		
			
			| 
				57
			 | 
			
				53
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				58
			 | 
			
				
			 | 
			
			
				
				-/****************************************************************************** 
			 | 
		
		
	
		
			
			| 
				59
			 | 
			
				
			 | 
			
			
				
				- * 
			 | 
		
		
	
		
			
			| 
				60
			 | 
			
				
			 | 
			
			
				
				- * Ring management 
			 | 
		
		
	
		
			
			| 
				61
			 | 
			
				
			 | 
			
			
				
				- * 
			 | 
		
		
	
		
			
			| 
				62
			 | 
			
				
			 | 
			
			
				
				- ****************************************************************************** 
			 | 
		
		
	
		
			
			| 
				63
			 | 
			
				
			 | 
			
			
				
				- */ 
			 | 
		
		
	
		
			
			| 
				64
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				65
			 | 
			
				
			 | 
			
			
				
				-/** 
			 | 
		
		
	
		
			
			| 
				66
			 | 
			
				
			 | 
			
			
				
				- * Transcribe receive ring name (for debugging) 
			 | 
		
		
	
		
			
			| 
				67
			 | 
			
				
			 | 
			
			
				
				- * 
			 | 
		
		
	
		
			
			| 
				68
			 | 
			
				
			 | 
			
			
				
				- * @v ncm		CDC-NCM device 
			 | 
		
		
	
		
			
			| 
				69
			 | 
			
				
			 | 
			
			
				
				- * @v ring		Receive ring 
			 | 
		
		
	
		
			
			| 
				70
			 | 
			
				
			 | 
			
			
				
				- * @ret name		Receive ring name 
			 | 
		
		
	
		
			
			| 
				71
			 | 
			
				
			 | 
			
			
				
				- */ 
			 | 
		
		
	
		
			
			| 
				72
			 | 
			
				
			 | 
			
			
				
				-static inline const char * ncm_rx_name ( struct ncm_device *ncm, 
			 | 
		
		
	
		
			
			| 
				73
			 | 
			
				
			 | 
			
			
				
				-					 struct ncm_rx_ring *ring ) { 
			 | 
		
		
	
		
			
			| 
				74
			 | 
			
				
			 | 
			
			
				
				-	if ( ring == &ncm->intr ) { 
			 | 
		
		
	
		
			
			| 
				75
			 | 
			
				
			 | 
			
			
				
				-		return "interrupt"; 
			 | 
		
		
	
		
			
			| 
				76
			 | 
			
				
			 | 
			
			
				
				-	} else if ( ring == &ncm->in ) { 
			 | 
		
		
	
		
			
			| 
				77
			 | 
			
				
			 | 
			
			
				
				-		return "bulk IN"; 
			 | 
		
		
	
		
			
			| 
				78
			 | 
			
				
			 | 
			
			
				
				-	} else { 
			 | 
		
		
	
		
			
			| 
				79
			 | 
			
				
			 | 
			
			
				
				-		return "UNKNOWN"; 
			 | 
		
		
	
		
			
			| 
				80
			 | 
			
				
			 | 
			
			
				
				-	} 
			 | 
		
		
	
		
			
			| 
				81
			 | 
			
				
			 | 
			
			
				
				-} 
			 | 
		
		
	
		
			
			| 
				82
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				83
			 | 
			
				
			 | 
			
			
				
				-/** 
			 | 
		
		
	
		
			
			| 
				84
			 | 
			
				
			 | 
			
			
				
				- * Allocate receive ring buffers 
			 | 
		
		
	
		
			
			| 
				85
			 | 
			
				
			 | 
			
			
				
				- * 
			 | 
		
		
	
		
			
			| 
				86
			 | 
			
				
			 | 
			
			
				
				- * @v ncm		CDC-NCM device 
			 | 
		
		
	
		
			
			| 
				87
			 | 
			
				
			 | 
			
			
				
				- * @v ring		Receive ring 
			 | 
		
		
	
		
			
			| 
				88
			 | 
			
				
			 | 
			
			
				
				- * @v mtu		I/O buffer size 
			 | 
		
		
	
		
			
			| 
				89
			 | 
			
				
			 | 
			
			
				
				- * @v count		Number of I/O buffers 
			 | 
		
		
	
		
			
			| 
				90
			 | 
			
				
			 | 
			
			
				
				- * @ret rc		Return status code 
			 | 
		
		
	
		
			
			| 
				91
			 | 
			
				
			 | 
			
			
				
				- */ 
			 | 
		
		
	
		
			
			| 
				92
			 | 
			
				
			 | 
			
			
				
				-static int ncm_rx_alloc ( struct ncm_device *ncm, struct ncm_rx_ring *ring, 
			 | 
		
		
	
		
			
			| 
				93
			 | 
			
				
			 | 
			
			
				
				-			  size_t mtu, unsigned int count ) { 
			 | 
		
		
	
		
			
			| 
				94
			 | 
			
				
			 | 
			
			
				
				-	struct io_buffer *iobuf; 
			 | 
		
		
	
		
			
			| 
				95
			 | 
			
				
			 | 
			
			
				
				-	struct io_buffer *tmp; 
			 | 
		
		
	
		
			
			| 
				96
			 | 
			
				
			 | 
			
			
				
				-	unsigned int i; 
			 | 
		
		
	
		
			
			| 
				97
			 | 
			
				
			 | 
			
			
				
				-	int rc; 
			 | 
		
		
	
		
			
			| 
				98
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				99
			 | 
			
				
			 | 
			
			
				
				-	/* Initialise ring */ 
			 | 
		
		
	
		
			
			| 
				100
			 | 
			
				
			 | 
			
			
				
				-	ring->mtu = mtu; 
			 | 
		
		
	
		
			
			| 
				101
			 | 
			
				
			 | 
			
			
				
				-	INIT_LIST_HEAD ( &ring->list ); 
			 | 
		
		
	
		
			
			| 
				102
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				103
			 | 
			
				
			 | 
			
			
				
				-	/* Allocate I/O buffers */ 
			 | 
		
		
	
		
			
			| 
				104
			 | 
			
				
			 | 
			
			
				
				-	for ( i = 0 ; i < count ; i++ ) { 
			 | 
		
		
	
		
			
			| 
				105
			 | 
			
				
			 | 
			
			
				
				-		iobuf = alloc_iob ( mtu ); 
			 | 
		
		
	
		
			
			| 
				106
			 | 
			
				
			 | 
			
			
				
				-		if ( ! iobuf ) { 
			 | 
		
		
	
		
			
			| 
				107
			 | 
			
				
			 | 
			
			
				
				-			DBGC ( ncm, "NCM %p could not allocate %dx %zd-byte " 
			 | 
		
		
	
		
			
			| 
				108
			 | 
			
				
			 | 
			
			
				
				-			       "buffers for %s\n", ncm, count, mtu, 
			 | 
		
		
	
		
			
			| 
				109
			 | 
			
				
			 | 
			
			
				
				-			       ncm_rx_name ( ncm, ring ) ); 
			 | 
		
		
	
		
			
			| 
				110
			 | 
			
				
			 | 
			
			
				
				-			rc = -ENOMEM; 
			 | 
		
		
	
		
			
			| 
				111
			 | 
			
				
			 | 
			
			
				
				-			goto err_alloc; 
			 | 
		
		
	
		
			
			| 
				112
			 | 
			
				
			 | 
			
			
				
				-		} 
			 | 
		
		
	
		
			
			| 
				113
			 | 
			
				
			 | 
			
			
				
				-		list_add ( &iobuf->list, &ring->list ); 
			 | 
		
		
	
		
			
			| 
				114
			 | 
			
				
			 | 
			
			
				
				-	} 
			 | 
		
		
	
		
			
			| 
				115
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				116
			 | 
			
				
			 | 
			
			
				
				-	return 0; 
			 | 
		
		
	
		
			
			| 
				117
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				118
			 | 
			
				
			 | 
			
			
				
				- err_alloc: 
			 | 
		
		
	
		
			
			| 
				119
			 | 
			
				
			 | 
			
			
				
				-	list_for_each_entry_safe ( iobuf, tmp, &ring->list, list ) { 
			 | 
		
		
	
		
			
			| 
				120
			 | 
			
				
			 | 
			
			
				
				-		list_del ( &iobuf->list ); 
			 | 
		
		
	
		
			
			| 
				121
			 | 
			
				
			 | 
			
			
				
				-		free_iob ( iobuf ); 
			 | 
		
		
	
		
			
			| 
				122
			 | 
			
				
			 | 
			
			
				
				-	} 
			 | 
		
		
	
		
			
			| 
				123
			 | 
			
				
			 | 
			
			
				
				-	return rc; 
			 | 
		
		
	
		
			
			| 
				124
			 | 
			
				
			 | 
			
			
				
				-} 
			 | 
		
		
	
		
			
			| 
				125
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				126
			 | 
			
				
			 | 
			
			
				
				-/** 
			 | 
		
		
	
		
			
			| 
				127
			 | 
			
				
			 | 
			
			
				
				- * Refill receive ring 
			 | 
		
		
	
		
			
			| 
				128
			 | 
			
				
			 | 
			
			
				
				- * 
			 | 
		
		
	
		
			
			| 
				129
			 | 
			
				
			 | 
			
			
				
				- * @v ncm		CDC-NCM device 
			 | 
		
		
	
		
			
			| 
				130
			 | 
			
				
			 | 
			
			
				
				- * @v ring		Receive ring 
			 | 
		
		
	
		
			
			| 
				131
			 | 
			
				
			 | 
			
			
				
				- * @ret rc		Return status code 
			 | 
		
		
	
		
			
			| 
				132
			 | 
			
				
			 | 
			
			
				
				- */ 
			 | 
		
		
	
		
			
			| 
				133
			 | 
			
				
			 | 
			
			
				
				-static int ncm_rx_refill ( struct ncm_device *ncm, struct ncm_rx_ring *ring ) { 
			 | 
		
		
	
		
			
			| 
				134
			 | 
			
				
			 | 
			
			
				
				-	struct io_buffer *iobuf; 
			 | 
		
		
	
		
			
			| 
				135
			 | 
			
				
			 | 
			
			
				
				-	int rc; 
			 | 
		
		
	
		
			
			| 
				136
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				137
			 | 
			
				
			 | 
			
			
				
				-	/* Enqueue any recycled I/O buffers */ 
			 | 
		
		
	
		
			
			| 
				138
			 | 
			
				
			 | 
			
			
				
				-	while ( ( iobuf = list_first_entry ( &ring->list, struct io_buffer, 
			 | 
		
		
	
		
			
			| 
				139
			 | 
			
				
			 | 
			
			
				
				-					     list ) ) ) { 
			 | 
		
		
	
		
			
			| 
				140
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				141
			 | 
			
				
			 | 
			
			
				
				-		/* Profile refill */ 
			 | 
		
		
	
		
			
			| 
				142
			 | 
			
				
			 | 
			
			
				
				-		profile_start ( &ncm_refill_profiler ); 
			 | 
		
		
	
		
			
			| 
				143
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				144
			 | 
			
				
			 | 
			
			
				
				-		/* Reset size */ 
			 | 
		
		
	
		
			
			| 
				145
			 | 
			
				
			 | 
			
			
				
				-		iob_put ( iobuf, ( ring->mtu - iob_len ( iobuf ) ) ); 
			 | 
		
		
	
		
			
			| 
				146
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				147
			 | 
			
				
			 | 
			
			
				
				-		/* Enqueue I/O buffer */ 
			 | 
		
		
	
		
			
			| 
				148
			 | 
			
				
			 | 
			
			
				
				-		if ( ( rc = usb_stream ( &ring->ep, iobuf, 0 ) ) != 0 ) { 
			 | 
		
		
	
		
			
			| 
				149
			 | 
			
				
			 | 
			
			
				
				-			DBGC ( ncm, "NCM %p could not enqueue %s: %s\n", ncm, 
			 | 
		
		
	
		
			
			| 
				150
			 | 
			
				
			 | 
			
			
				
				-			       ncm_rx_name ( ncm, ring ), strerror ( rc ) ); 
			 | 
		
		
	
		
			
			| 
				151
			 | 
			
				
			 | 
			
			
				
				-			/* Leave in recycled list and wait for next refill */ 
			 | 
		
		
	
		
			
			| 
				152
			 | 
			
				
			 | 
			
			
				
				-			return rc; 
			 | 
		
		
	
		
			
			| 
				153
			 | 
			
				
			 | 
			
			
				
				-		} 
			 | 
		
		
	
		
			
			| 
				154
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				155
			 | 
			
				
			 | 
			
			
				
				-		/* Remove from recycled list */ 
			 | 
		
		
	
		
			
			| 
				156
			 | 
			
				
			 | 
			
			
				
				-		list_del ( &iobuf->list ); 
			 | 
		
		
	
		
			
			| 
				157
			 | 
			
				
			 | 
			
			
				
				-		profile_stop ( &ncm_refill_profiler ); 
			 | 
		
		
	
		
			
			| 
				158
			 | 
			
				
			 | 
			
			
				
				-	} 
			 | 
		
		
	
		
			
			| 
				159
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				160
			 | 
			
				
			 | 
			
			
				
				-	return 0; 
			 | 
		
		
	
		
			
			| 
				161
			 | 
			
				
			 | 
			
			
				
				-} 
			 | 
		
		
	
		
			
			| 
				162
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				163
			 | 
			
				
			 | 
			
			
				
				-/** 
			 | 
		
		
	
		
			
			| 
				164
			 | 
			
				
			 | 
			
			
				
				- * Recycle receive buffer 
			 | 
		
		
	
		
			
			| 
				165
			 | 
			
				
			 | 
			
			
				
				- * 
			 | 
		
		
	
		
			
			| 
				166
			 | 
			
				
			 | 
			
			
				
				- * @v ncm		CDC-NCM device 
			 | 
		
		
	
		
			
			| 
				167
			 | 
			
				
			 | 
			
			
				
				- * @v ring		Receive ring 
			 | 
		
		
	
		
			
			| 
				168
			 | 
			
				
			 | 
			
			
				
				- * @v iobuf		I/O buffer 
			 | 
		
		
	
		
			
			| 
				169
			 | 
			
				
			 | 
			
			
				
				- */ 
			 | 
		
		
	
		
			
			| 
				170
			 | 
			
				
			 | 
			
			
				
				-static inline void ncm_rx_recycle ( struct ncm_device *ncm __unused, 
			 | 
		
		
	
		
			
			| 
				171
			 | 
			
				
			 | 
			
			
				
				-				    struct ncm_rx_ring *ring, 
			 | 
		
		
	
		
			
			| 
				172
			 | 
			
				
			 | 
			
			
				
				-				    struct io_buffer *iobuf ) { 
			 | 
		
		
	
		
			
			| 
				173
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				174
			 | 
			
				
			 | 
			
			
				
				-	/* Add to recycled list */ 
			 | 
		
		
	
		
			
			| 
				175
			 | 
			
				
			 | 
			
			
				
				-	list_add_tail ( &iobuf->list, &ring->list ); 
			 | 
		
		
	
		
			
			| 
				176
			 | 
			
				
			 | 
			
			
				
				-} 
			 | 
		
		
	
		
			
			| 
				177
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				178
			 | 
			
				
			 | 
			
			
				
				-/** 
			 | 
		
		
	
		
			
			| 
				179
			 | 
			
				
			 | 
			
			
				
				- * Free receive ring 
			 | 
		
		
	
		
			
			| 
				180
			 | 
			
				
			 | 
			
			
				
				- * 
			 | 
		
		
	
		
			
			| 
				181
			 | 
			
				
			 | 
			
			
				
				- * @v ncm		CDC-NCM device 
			 | 
		
		
	
		
			
			| 
				182
			 | 
			
				
			 | 
			
			
				
				- * @v ring		Receive ring 
			 | 
		
		
	
		
			
			| 
				183
			 | 
			
				
			 | 
			
			
				
				- */ 
			 | 
		
		
	
		
			
			| 
				184
			 | 
			
				
			 | 
			
			
				
				-static void ncm_rx_free ( struct ncm_device *ncm __unused, 
			 | 
		
		
	
		
			
			| 
				185
			 | 
			
				
			 | 
			
			
				
				-			  struct ncm_rx_ring *ring ) { 
			 | 
		
		
	
		
			
			| 
				186
			 | 
			
				
			 | 
			
			
				
				-	struct io_buffer *iobuf; 
			 | 
		
		
	
		
			
			| 
				187
			 | 
			
				
			 | 
			
			
				
				-	struct io_buffer *tmp; 
			 | 
		
		
	
		
			
			| 
				188
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				189
			 | 
			
				
			 | 
			
			
				
				-	/* Free I/O buffers */ 
			 | 
		
		
	
		
			
			| 
				190
			 | 
			
				
			 | 
			
			
				
				-	list_for_each_entry_safe ( iobuf, tmp, &ring->list, list ) { 
			 | 
		
		
	
		
			
			| 
				191
			 | 
			
				
			 | 
			
			
				
				-		list_del ( &iobuf->list ); 
			 | 
		
		
	
		
			
			| 
				192
			 | 
			
				
			 | 
			
			
				
				-		free_iob ( iobuf ); 
			 | 
		
		
	
		
			
			| 
				193
			 | 
			
				
			 | 
			
			
				
				-	} 
			 | 
		
		
	
		
			
			| 
				194
			 | 
			
				
			 | 
			
			
				
				-} 
			 | 
		
		
	
		
			
			| 
				195
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				196
			 | 
			
				54
			 | 
			
			
				
				 /****************************************************************************** 
			 | 
		
		
	
		
			
			| 
				197
			 | 
			
				55
			 | 
			
			
				
				  * 
			 | 
		
		
	
		
			
			| 
				198
			 | 
			
				56
			 | 
			
			
				
				  * CDC-NCM communications interface 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -209,7 +67,7 @@ static void ncm_rx_free ( struct ncm_device *ncm __unused, 
			 | 
		
		
	
		
			
			| 
				209
			 | 
			
				67
			 | 
			
			
				
				  */ 
			 | 
		
		
	
		
			
			| 
				210
			 | 
			
				68
			 | 
			
			
				
				 static void ncm_intr_complete ( struct usb_endpoint *ep, 
			 | 
		
		
	
		
			
			| 
				211
			 | 
			
				69
			 | 
			
			
				
				 				struct io_buffer *iobuf, int rc ) { 
			 | 
		
		
	
		
			
			| 
				212
			 | 
			
				
			 | 
			
			
				
				-	struct ncm_device *ncm = container_of ( ep, struct ncm_device, intr.ep); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				70
			 | 
			
			
				
				+	struct ncm_device *ncm = container_of ( ep, struct ncm_device, intr ); 
			 | 
		
		
	
		
			
			| 
				213
			 | 
			
				71
			 | 
			
			
				
				 	struct net_device *netdev = ncm->netdev; 
			 | 
		
		
	
		
			
			| 
				214
			 | 
			
				72
			 | 
			
			
				
				 	struct usb_setup_packet *message; 
			 | 
		
		
	
		
			
			| 
				215
			 | 
			
				73
			 | 
			
			
				
				 	size_t len = iob_len ( iobuf ); 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -219,21 +77,22 @@ static void ncm_intr_complete ( struct usb_endpoint *ep, 
			 | 
		
		
	
		
			
			| 
				219
			 | 
			
				77
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				220
			 | 
			
				78
			 | 
			
			
				
				 	/* Ignore packets cancelled when the endpoint closes */ 
			 | 
		
		
	
		
			
			| 
				221
			 | 
			
				79
			 | 
			
			
				
				 	if ( ! ep->open ) 
			 | 
		
		
	
		
			
			| 
				222
			 | 
			
				
			 | 
			
			
				
				-		goto done; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				80
			 | 
			
			
				
				+		goto ignore; 
			 | 
		
		
	
		
			
			| 
				223
			 | 
			
				81
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				224
			 | 
			
				82
			 | 
			
			
				
				 	/* Ignore packets with errors */ 
			 | 
		
		
	
		
			
			| 
				225
			 | 
			
				83
			 | 
			
			
				
				 	if ( rc != 0 ) { 
			 | 
		
		
	
		
			
			| 
				226
			 | 
			
				84
			 | 
			
			
				
				 		DBGC ( ncm, "NCM %p interrupt failed: %s\n", 
			 | 
		
		
	
		
			
			| 
				227
			 | 
			
				85
			 | 
			
			
				
				 		       ncm, strerror ( rc ) ); 
			 | 
		
		
	
		
			
			| 
				228
			 | 
			
				86
			 | 
			
			
				
				 		DBGC_HDA ( ncm, 0, iobuf->data, iob_len ( iobuf ) ); 
			 | 
		
		
	
		
			
			| 
				229
			 | 
			
				
			 | 
			
			
				
				-		goto done; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				87
			 | 
			
			
				
				+		goto error; 
			 | 
		
		
	
		
			
			| 
				230
			 | 
			
				88
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				231
			 | 
			
				89
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				232
			 | 
			
				90
			 | 
			
			
				
				 	/* Extract message header */ 
			 | 
		
		
	
		
			
			| 
				233
			 | 
			
				91
			 | 
			
			
				
				 	if ( len < sizeof ( *message ) ) { 
			 | 
		
		
	
		
			
			| 
				234
			 | 
			
				92
			 | 
			
			
				
				 		DBGC ( ncm, "NCM %p underlength interrupt:\n", ncm ); 
			 | 
		
		
	
		
			
			| 
				235
			 | 
			
				93
			 | 
			
			
				
				 		DBGC_HDA ( ncm, 0, iobuf->data, iob_len ( iobuf ) ); 
			 | 
		
		
	
		
			
			| 
				236
			 | 
			
				
			 | 
			
			
				
				-		goto done; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				94
			 | 
			
			
				
				+		rc = -EINVAL; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				95
			 | 
			
			
				
				+		goto error; 
			 | 
		
		
	
		
			
			| 
				237
			 | 
			
				96
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				238
			 | 
			
				97
			 | 
			
			
				
				 	message = iobuf->data; 
			 | 
		
		
	
		
			
			| 
				239
			 | 
			
				98
			 | 
			
			
				
				  
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -257,13 +116,20 @@ static void ncm_intr_complete ( struct usb_endpoint *ep, 
			 | 
		
		
	
		
			
			| 
				257
			 | 
			
				116
			 | 
			
			
				
				 	default: 
			 | 
		
		
	
		
			
			| 
				258
			 | 
			
				117
			 | 
			
			
				
				 		DBGC ( ncm, "NCM %p unrecognised interrupt:\n", ncm ); 
			 | 
		
		
	
		
			
			| 
				259
			 | 
			
				118
			 | 
			
			
				
				 		DBGC_HDA ( ncm, 0, iobuf->data, iob_len ( iobuf ) ); 
			 | 
		
		
	
		
			
			| 
				260
			 | 
			
				
			 | 
			
			
				
				-		break; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				119
			 | 
			
			
				
				+		goto error; 
			 | 
		
		
	
		
			
			| 
				261
			 | 
			
				120
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				262
			 | 
			
				121
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				263
			 | 
			
				
			 | 
			
			
				
				- done: 
			 | 
		
		
	
		
			
			| 
				264
			 | 
			
				
			 | 
			
			
				
				-	/* Recycle buffer */ 
			 | 
		
		
	
		
			
			| 
				265
			 | 
			
				
			 | 
			
			
				
				-	ncm_rx_recycle ( ncm, &ncm->intr, iobuf ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				122
			 | 
			
			
				
				+	/* Free I/O buffer */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				123
			 | 
			
			
				
				+	free_iob ( iobuf ); 
			 | 
		
		
	
		
			
			| 
				266
			 | 
			
				124
			 | 
			
			
				
				 	profile_stop ( &ncm_intr_profiler ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				125
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				126
			 | 
			
			
				
				+	return; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				127
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				128
			 | 
			
			
				
				+ error: 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				129
			 | 
			
			
				
				+	netdev_rx_err ( netdev, iob_disown ( iobuf ), rc ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				130
			 | 
			
			
				
				+ ignore: 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				131
			 | 
			
			
				
				+	free_iob ( iobuf ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				132
			 | 
			
			
				
				+	return; 
			 | 
		
		
	
		
			
			| 
				267
			 | 
			
				133
			 | 
			
			
				
				 } 
			 | 
		
		
	
		
			
			| 
				268
			 | 
			
				134
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				269
			 | 
			
				135
			 | 
			
			
				
				 /** Interrupt endpoint operations */ 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -280,27 +146,20 @@ static struct usb_endpoint_driver_operations ncm_intr_operations = { 
			 | 
		
		
	
		
			
			| 
				280
			 | 
			
				146
			 | 
			
			
				
				 static int ncm_comms_open ( struct ncm_device *ncm ) { 
			 | 
		
		
	
		
			
			| 
				281
			 | 
			
				147
			 | 
			
			
				
				 	int rc; 
			 | 
		
		
	
		
			
			| 
				282
			 | 
			
				148
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				283
			 | 
			
				
			 | 
			
			
				
				-	/* Allocate I/O buffers */ 
			 | 
		
		
	
		
			
			| 
				284
			 | 
			
				
			 | 
			
			
				
				-	if ( ( rc = ncm_rx_alloc ( ncm, &ncm->intr, ncm->intr.ep.mtu, 
			 | 
		
		
	
		
			
			| 
				285
			 | 
			
				
			 | 
			
			
				
				-				   NCM_INTR_COUNT ) ) != 0 ) { 
			 | 
		
		
	
		
			
			| 
				286
			 | 
			
				
			 | 
			
			
				
				-		DBGC ( ncm, "NCM %p could not allocate RX buffers: %s\n", 
			 | 
		
		
	
		
			
			| 
				287
			 | 
			
				
			 | 
			
			
				
				-		       ncm, strerror ( rc ) ); 
			 | 
		
		
	
		
			
			| 
				288
			 | 
			
				
			 | 
			
			
				
				-		goto err_alloc; 
			 | 
		
		
	
		
			
			| 
				289
			 | 
			
				
			 | 
			
			
				
				-	} 
			 | 
		
		
	
		
			
			| 
				290
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				291
			 | 
			
				149
			 | 
			
			
				
				 	/* Open interrupt endpoint */ 
			 | 
		
		
	
		
			
			| 
				292
			 | 
			
				
			 | 
			
			
				
				-	if ( ( rc = usb_endpoint_open ( &ncm->intr.ep ) ) != 0 ) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				150
			 | 
			
			
				
				+	if ( ( rc = usb_endpoint_open ( &ncm->intr ) ) != 0 ) { 
			 | 
		
		
	
		
			
			| 
				293
			 | 
			
				151
			 | 
			
			
				
				 		DBGC ( ncm, "NCM %p could not open interrupt: %s\n", 
			 | 
		
		
	
		
			
			| 
				294
			 | 
			
				152
			 | 
			
			
				
				 		       ncm, strerror ( rc ) ); 
			 | 
		
		
	
		
			
			| 
				295
			 | 
			
				153
			 | 
			
			
				
				 		goto err_open; 
			 | 
		
		
	
		
			
			| 
				296
			 | 
			
				154
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				297
			 | 
			
				155
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				156
			 | 
			
			
				
				+	/* Refill interrupt endpoint */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				157
			 | 
			
			
				
				+	usb_refill ( &ncm->intr ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				158
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				298
			 | 
			
				159
			 | 
			
			
				
				 	return 0; 
			 | 
		
		
	
		
			
			| 
				299
			 | 
			
				160
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				300
			 | 
			
				
			 | 
			
			
				
				-	usb_endpoint_close ( &ncm->intr.ep ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				161
			 | 
			
			
				
				+	usb_endpoint_close ( &ncm->intr ); 
			 | 
		
		
	
		
			
			| 
				301
			 | 
			
				162
			 | 
			
			
				
				  err_open: 
			 | 
		
		
	
		
			
			| 
				302
			 | 
			
				
			 | 
			
			
				
				-	ncm_rx_free ( ncm, &ncm->intr ); 
			 | 
		
		
	
		
			
			| 
				303
			 | 
			
				
			 | 
			
			
				
				- err_alloc: 
			 | 
		
		
	
		
			
			| 
				304
			 | 
			
				163
			 | 
			
			
				
				 	return rc; 
			 | 
		
		
	
		
			
			| 
				305
			 | 
			
				164
			 | 
			
			
				
				 } 
			 | 
		
		
	
		
			
			| 
				306
			 | 
			
				165
			 | 
			
			
				
				  
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -312,10 +171,7 @@ static int ncm_comms_open ( struct ncm_device *ncm ) { 
			 | 
		
		
	
		
			
			| 
				312
			 | 
			
				171
			 | 
			
			
				
				 static void ncm_comms_close ( struct ncm_device *ncm ) { 
			 | 
		
		
	
		
			
			| 
				313
			 | 
			
				172
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				314
			 | 
			
				173
			 | 
			
			
				
				 	/* Close interrupt endpoint */ 
			 | 
		
		
	
		
			
			| 
				315
			 | 
			
				
			 | 
			
			
				
				-	usb_endpoint_close ( &ncm->intr.ep ); 
			 | 
		
		
	
		
			
			| 
				316
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				317
			 | 
			
				
			 | 
			
			
				
				-	/* Free I/O buffers */ 
			 | 
		
		
	
		
			
			| 
				318
			 | 
			
				
			 | 
			
			
				
				-	ncm_rx_free ( ncm, &ncm->intr ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				174
			 | 
			
			
				
				+	usb_endpoint_close ( &ncm->intr ); 
			 | 
		
		
	
		
			
			| 
				319
			 | 
			
				175
			 | 
			
			
				
				 } 
			 | 
		
		
	
		
			
			| 
				320
			 | 
			
				176
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				321
			 | 
			
				177
			 | 
			
			
				
				 /****************************************************************************** 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -326,12 +182,12 @@ static void ncm_comms_close ( struct ncm_device *ncm ) { 
			 | 
		
		
	
		
			
			| 
				326
			 | 
			
				182
			 | 
			
			
				
				  */ 
			 | 
		
		
	
		
			
			| 
				327
			 | 
			
				183
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				328
			 | 
			
				184
			 | 
			
			
				
				 /** 
			 | 
		
		
	
		
			
			| 
				329
			 | 
			
				
			 | 
			
			
				
				- * Allocate bulk IN receive ring buffers 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				185
			 | 
			
			
				
				+ * Prefill bulk IN endpoint 
			 | 
		
		
	
		
			
			| 
				330
			 | 
			
				186
			 | 
			
			
				
				  * 
			 | 
		
		
	
		
			
			| 
				331
			 | 
			
				187
			 | 
			
			
				
				  * @v ncm		CDC-NCM device 
			 | 
		
		
	
		
			
			| 
				332
			 | 
			
				188
			 | 
			
			
				
				  * @ret rc		Return status code 
			 | 
		
		
	
		
			
			| 
				333
			 | 
			
				189
			 | 
			
			
				
				  */ 
			 | 
		
		
	
		
			
			| 
				334
			 | 
			
				
			 | 
			
			
				
				-static int ncm_in_alloc ( struct ncm_device *ncm ) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				190
			 | 
			
			
				
				+static int ncm_in_prefill ( struct ncm_device *ncm ) { 
			 | 
		
		
	
		
			
			| 
				335
			 | 
			
				191
			 | 
			
			
				
				 	size_t mtu; 
			 | 
		
		
	
		
			
			| 
				336
			 | 
			
				192
			 | 
			
			
				
				 	unsigned int count; 
			 | 
		
		
	
		
			
			| 
				337
			 | 
			
				193
			 | 
			
			
				
				 	int rc; 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -358,15 +214,19 @@ static int ncm_in_alloc ( struct ncm_device *ncm ) { 
			 | 
		
		
	
		
			
			| 
				358
			 | 
			
				214
			 | 
			
			
				
				 			count = NCM_IN_MIN_COUNT; 
			 | 
		
		
	
		
			
			| 
				359
			 | 
			
				215
			 | 
			
			
				
				 		if ( ( count * mtu ) > NCM_IN_MAX_SIZE ) 
			 | 
		
		
	
		
			
			| 
				360
			 | 
			
				216
			 | 
			
			
				
				 			continue; 
			 | 
		
		
	
		
			
			| 
				361
			 | 
			
				
			 | 
			
			
				
				-		if ( ( rc = ncm_rx_alloc ( ncm, &ncm->in, mtu, count ) ) != 0 ) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				217
			 | 
			
			
				
				+		usb_refill_init ( &ncm->in, mtu, count ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				218
			 | 
			
			
				
				+		if ( ( rc = usb_prefill ( &ncm->in ) ) != 0 ) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				219
			 | 
			
			
				
				+			DBGC ( ncm, "NCM %p could not prefill %dx %zd-byte " 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				220
			 | 
			
			
				
				+			       "buffers for bulk IN\n", ncm, count, mtu ); 
			 | 
		
		
	
		
			
			| 
				362
			 | 
			
				221
			 | 
			
			
				
				 			continue; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				222
			 | 
			
			
				
				+		} 
			 | 
		
		
	
		
			
			| 
				363
			 | 
			
				223
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				364
			 | 
			
				224
			 | 
			
			
				
				 		DBGC ( ncm, "NCM %p using %dx %zd-byte buffers for bulk IN\n", 
			 | 
		
		
	
		
			
			| 
				365
			 | 
			
				225
			 | 
			
			
				
				 		       ncm, count, mtu ); 
			 | 
		
		
	
		
			
			| 
				366
			 | 
			
				226
			 | 
			
			
				
				 		return 0; 
			 | 
		
		
	
		
			
			| 
				367
			 | 
			
				227
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				368
			 | 
			
				228
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				369
			 | 
			
				
			 | 
			
			
				
				-	DBGC ( ncm, "NCM %p could not allocate bulk IN buffers\n", ncm ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				229
			 | 
			
			
				
				+	DBGC ( ncm, "NCM %p could not prefill bulk IN endpoint\n", ncm ); 
			 | 
		
		
	
		
			
			| 
				370
			 | 
			
				230
			 | 
			
			
				
				 	return -ENOMEM; 
			 | 
		
		
	
		
			
			| 
				371
			 | 
			
				231
			 | 
			
			
				
				 } 
			 | 
		
		
	
		
			
			| 
				372
			 | 
			
				232
			 | 
			
			
				
				  
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -379,7 +239,7 @@ static int ncm_in_alloc ( struct ncm_device *ncm ) { 
			 | 
		
		
	
		
			
			| 
				379
			 | 
			
				239
			 | 
			
			
				
				  */ 
			 | 
		
		
	
		
			
			| 
				380
			 | 
			
				240
			 | 
			
			
				
				 static void ncm_in_complete ( struct usb_endpoint *ep, struct io_buffer *iobuf, 
			 | 
		
		
	
		
			
			| 
				381
			 | 
			
				241
			 | 
			
			
				
				 			      int rc ) { 
			 | 
		
		
	
		
			
			| 
				382
			 | 
			
				
			 | 
			
			
				
				-	struct ncm_device *ncm = container_of ( ep, struct ncm_device, in.ep ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				242
			 | 
			
			
				
				+	struct ncm_device *ncm = container_of ( ep, struct ncm_device, in ); 
			 | 
		
		
	
		
			
			| 
				383
			 | 
			
				243
			 | 
			
			
				
				 	struct net_device *netdev = ncm->netdev; 
			 | 
		
		
	
		
			
			| 
				384
			 | 
			
				244
			 | 
			
			
				
				 	struct ncm_transfer_header *nth; 
			 | 
		
		
	
		
			
			| 
				385
			 | 
			
				245
			 | 
			
			
				
				 	struct ncm_datagram_pointer *ndp; 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -404,13 +264,14 @@ static void ncm_in_complete ( struct usb_endpoint *ep, struct io_buffer *iobuf, 
			 | 
		
		
	
		
			
			| 
				404
			 | 
			
				264
			 | 
			
			
				
				 	if ( rc != 0 ) { 
			 | 
		
		
	
		
			
			| 
				405
			 | 
			
				265
			 | 
			
			
				
				 		DBGC ( ncm, "NCM %p bulk IN failed: %s\n", 
			 | 
		
		
	
		
			
			| 
				406
			 | 
			
				266
			 | 
			
			
				
				 		       ncm, strerror ( rc ) ); 
			 | 
		
		
	
		
			
			| 
				407
			 | 
			
				
			 | 
			
			
				
				-		goto drop; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				267
			 | 
			
			
				
				+		goto error; 
			 | 
		
		
	
		
			
			| 
				408
			 | 
			
				268
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				409
			 | 
			
				269
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				410
			 | 
			
				270
			 | 
			
			
				
				 	/* Locate transfer header */ 
			 | 
		
		
	
		
			
			| 
				411
			 | 
			
				271
			 | 
			
			
				
				 	len = iob_len ( iobuf ); 
			 | 
		
		
	
		
			
			| 
				412
			 | 
			
				272
			 | 
			
			
				
				 	if ( sizeof ( *nth ) > len ) { 
			 | 
		
		
	
		
			
			| 
				413
			 | 
			
				273
			 | 
			
			
				
				 		DBGC ( ncm, "NCM %p packet too short for NTH:\n", ncm ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				274
			 | 
			
			
				
				+		rc = -EINVAL; 
			 | 
		
		
	
		
			
			| 
				414
			 | 
			
				275
			 | 
			
			
				
				 		goto error; 
			 | 
		
		
	
		
			
			| 
				415
			 | 
			
				276
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				416
			 | 
			
				277
			 | 
			
			
				
				 	nth = iobuf->data; 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -419,16 +280,19 @@ static void ncm_in_complete ( struct usb_endpoint *ep, struct io_buffer *iobuf, 
			 | 
		
		
	
		
			
			| 
				419
			 | 
			
				280
			 | 
			
			
				
				 	ndp_offset = le16_to_cpu ( nth->offset ); 
			 | 
		
		
	
		
			
			| 
				420
			 | 
			
				281
			 | 
			
			
				
				 	if ( ( ndp_offset + sizeof ( *ndp ) ) > len ) { 
			 | 
		
		
	
		
			
			| 
				421
			 | 
			
				282
			 | 
			
			
				
				 		DBGC ( ncm, "NCM %p packet too short for NDP:\n", ncm ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				283
			 | 
			
			
				
				+		rc = -EINVAL; 
			 | 
		
		
	
		
			
			| 
				422
			 | 
			
				284
			 | 
			
			
				
				 		goto error; 
			 | 
		
		
	
		
			
			| 
				423
			 | 
			
				285
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				424
			 | 
			
				286
			 | 
			
			
				
				 	ndp = ( iobuf->data + ndp_offset ); 
			 | 
		
		
	
		
			
			| 
				425
			 | 
			
				287
			 | 
			
			
				
				 	ndp_len = le16_to_cpu ( ndp->header_len ); 
			 | 
		
		
	
		
			
			| 
				426
			 | 
			
				288
			 | 
			
			
				
				 	if ( ndp_len < offsetof ( typeof ( *ndp ), desc ) ) { 
			 | 
		
		
	
		
			
			| 
				427
			 | 
			
				289
			 | 
			
			
				
				 		DBGC ( ncm, "NCM %p NDP header length too short:\n", ncm ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				290
			 | 
			
			
				
				+		rc = -EINVAL; 
			 | 
		
		
	
		
			
			| 
				428
			 | 
			
				291
			 | 
			
			
				
				 		goto error; 
			 | 
		
		
	
		
			
			| 
				429
			 | 
			
				292
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				430
			 | 
			
				293
			 | 
			
			
				
				 	if ( ( ndp_offset + ndp_len ) > len ) { 
			 | 
		
		
	
		
			
			| 
				431
			 | 
			
				294
			 | 
			
			
				
				 		DBGC ( ncm, "NCM %p packet too short for NDP:\n", ncm ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				295
			 | 
			
			
				
				+		rc = -EINVAL; 
			 | 
		
		
	
		
			
			| 
				432
			 | 
			
				296
			 | 
			
			
				
				 		goto error; 
			 | 
		
		
	
		
			
			| 
				433
			 | 
			
				297
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				434
			 | 
			
				298
			 | 
			
			
				
				  
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -445,10 +309,12 @@ static void ncm_in_complete ( struct usb_endpoint *ep, struct io_buffer *iobuf, 
			 | 
		
		
	
		
			
			| 
				445
			 | 
			
				309
			 | 
			
			
				
				 		pkt_len = le16_to_cpu ( desc->len ); 
			 | 
		
		
	
		
			
			| 
				446
			 | 
			
				310
			 | 
			
			
				
				 		if ( pkt_len < ETH_HLEN ) { 
			 | 
		
		
	
		
			
			| 
				447
			 | 
			
				311
			 | 
			
			
				
				 			DBGC ( ncm, "NCM %p underlength datagram:\n", ncm ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				312
			 | 
			
			
				
				+			rc = -EINVAL; 
			 | 
		
		
	
		
			
			| 
				448
			 | 
			
				313
			 | 
			
			
				
				 			goto error; 
			 | 
		
		
	
		
			
			| 
				449
			 | 
			
				314
			 | 
			
			
				
				 		} 
			 | 
		
		
	
		
			
			| 
				450
			 | 
			
				315
			 | 
			
			
				
				 		if ( ( pkt_offset + pkt_len ) > len ) { 
			 | 
		
		
	
		
			
			| 
				451
			 | 
			
				316
			 | 
			
			
				
				 			DBGC ( ncm, "NCM %p datagram exceeds packet:\n", ncm ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				317
			 | 
			
			
				
				+			rc = -EINVAL; 
			 | 
		
		
	
		
			
			| 
				452
			 | 
			
				318
			 | 
			
			
				
				 			goto error; 
			 | 
		
		
	
		
			
			| 
				453
			 | 
			
				319
			 | 
			
			
				
				 		} 
			 | 
		
		
	
		
			
			| 
				454
			 | 
			
				320
			 | 
			
			
				
				  
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -468,8 +334,7 @@ static void ncm_in_complete ( struct usb_endpoint *ep, struct io_buffer *iobuf, 
			 | 
		
		
	
		
			
			| 
				468
			 | 
			
				334
			 | 
			
			
				
				 		 * received packet and reuse the same I/O buffer for 
			 | 
		
		
	
		
			
			| 
				469
			 | 
			
				335
			 | 
			
			
				
				 		 * transmission. 
			 | 
		
		
	
		
			
			| 
				470
			 | 
			
				336
			 | 
			
			
				
				 		 */ 
			 | 
		
		
	
		
			
			| 
				471
			 | 
			
				
			 | 
			
			
				
				-		headroom = ( sizeof ( struct ncm_ntb_header ) + 
			 | 
		
		
	
		
			
			| 
				472
			 | 
			
				
			 | 
			
			
				
				-			     ncm->out.padding ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				337
			 | 
			
			
				
				+		headroom = ( sizeof ( struct ncm_ntb_header ) + ncm->padding ); 
			 | 
		
		
	
		
			
			| 
				473
			 | 
			
				338
			 | 
			
			
				
				 		pkt = alloc_iob ( headroom + pkt_len ); 
			 | 
		
		
	
		
			
			| 
				474
			 | 
			
				339
			 | 
			
			
				
				 		if ( ! pkt ) { 
			 | 
		
		
	
		
			
			| 
				475
			 | 
			
				340
			 | 
			
			
				
				 			/* Record error and continue */ 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -490,19 +355,17 @@ static void ncm_in_complete ( struct usb_endpoint *ep, struct io_buffer *iobuf, 
			 | 
		
		
	
		
			
			| 
				490
			 | 
			
				355
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				491
			 | 
			
				356
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				492
			 | 
			
				357
			 | 
			
			
				
				 	/* Recycle I/O buffer */ 
			 | 
		
		
	
		
			
			| 
				493
			 | 
			
				
			 | 
			
			
				
				-	ncm_rx_recycle ( ncm, &ncm->in, iobuf ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				358
			 | 
			
			
				
				+	usb_recycle ( &ncm->in, iobuf ); 
			 | 
		
		
	
		
			
			| 
				494
			 | 
			
				359
			 | 
			
			
				
				 	profile_stop ( &ncm_in_profiler ); 
			 | 
		
		
	
		
			
			| 
				495
			 | 
			
				360
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				496
			 | 
			
				361
			 | 
			
			
				
				 	return; 
			 | 
		
		
	
		
			
			| 
				497
			 | 
			
				362
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				498
			 | 
			
				363
			 | 
			
			
				
				  error: 
			 | 
		
		
	
		
			
			| 
				499
			 | 
			
				
			 | 
			
			
				
				-	rc = -EIO; 
			 | 
		
		
	
		
			
			| 
				500
			 | 
			
				
			 | 
			
			
				
				- drop: 
			 | 
		
		
	
		
			
			| 
				501
			 | 
			
				364
			 | 
			
			
				
				 	/* Record error against network device */ 
			 | 
		
		
	
		
			
			| 
				502
			 | 
			
				365
			 | 
			
			
				
				 	DBGC_HDA ( ncm, 0, iobuf->data, iob_len ( iobuf ) ); 
			 | 
		
		
	
		
			
			| 
				503
			 | 
			
				366
			 | 
			
			
				
				 	netdev_rx_err ( netdev, NULL, rc ); 
			 | 
		
		
	
		
			
			| 
				504
			 | 
			
				367
			 | 
			
			
				
				  ignore: 
			 | 
		
		
	
		
			
			| 
				505
			 | 
			
				
			 | 
			
			
				
				-	ncm_rx_recycle ( ncm, &ncm->in, iobuf ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				368
			 | 
			
			
				
				+	usb_recycle ( &ncm->in, iobuf ); 
			 | 
		
		
	
		
			
			| 
				506
			 | 
			
				369
			 | 
			
			
				
				 } 
			 | 
		
		
	
		
			
			| 
				507
			 | 
			
				370
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				508
			 | 
			
				371
			 | 
			
			
				
				 /** Bulk IN endpoint operations */ 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -521,7 +384,7 @@ static int ncm_out_transmit ( struct ncm_device *ncm, 
			 | 
		
		
	
		
			
			| 
				521
			 | 
			
				384
			 | 
			
			
				
				 			      struct io_buffer *iobuf ) { 
			 | 
		
		
	
		
			
			| 
				522
			 | 
			
				385
			 | 
			
			
				
				 	struct ncm_ntb_header *header; 
			 | 
		
		
	
		
			
			| 
				523
			 | 
			
				386
			 | 
			
			
				
				 	size_t len = iob_len ( iobuf ); 
			 | 
		
		
	
		
			
			| 
				524
			 | 
			
				
			 | 
			
			
				
				-	size_t header_len = ( sizeof ( *header ) + ncm->out.padding ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				387
			 | 
			
			
				
				+	size_t header_len = ( sizeof ( *header ) + ncm->padding ); 
			 | 
		
		
	
		
			
			| 
				525
			 | 
			
				388
			 | 
			
			
				
				 	int rc; 
			 | 
		
		
	
		
			
			| 
				526
			 | 
			
				389
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				527
			 | 
			
				390
			 | 
			
			
				
				 	/* Profile transmissions */ 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -535,7 +398,7 @@ static int ncm_out_transmit ( struct ncm_device *ncm, 
			 | 
		
		
	
		
			
			| 
				535
			 | 
			
				398
			 | 
			
			
				
				 	/* Populate header */ 
			 | 
		
		
	
		
			
			| 
				536
			 | 
			
				399
			 | 
			
			
				
				 	header->nth.magic = cpu_to_le32 ( NCM_TRANSFER_HEADER_MAGIC ); 
			 | 
		
		
	
		
			
			| 
				537
			 | 
			
				400
			 | 
			
			
				
				 	header->nth.header_len = cpu_to_le16 ( sizeof ( header->nth ) ); 
			 | 
		
		
	
		
			
			| 
				538
			 | 
			
				
			 | 
			
			
				
				-	header->nth.sequence = cpu_to_le16 ( ncm->out.sequence ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				401
			 | 
			
			
				
				+	header->nth.sequence = cpu_to_le16 ( ncm->sequence ); 
			 | 
		
		
	
		
			
			| 
				539
			 | 
			
				402
			 | 
			
			
				
				 	header->nth.len = cpu_to_le16 ( iob_len ( iobuf ) ); 
			 | 
		
		
	
		
			
			| 
				540
			 | 
			
				403
			 | 
			
			
				
				 	header->nth.offset = 
			 | 
		
		
	
		
			
			| 
				541
			 | 
			
				404
			 | 
			
			
				
				 		cpu_to_le16 ( offsetof ( typeof ( *header ), ndp ) ); 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -548,11 +411,11 @@ static int ncm_out_transmit ( struct ncm_device *ncm, 
			 | 
		
		
	
		
			
			| 
				548
			 | 
			
				411
			 | 
			
			
				
				 	memset ( &header->desc[1], 0, sizeof ( header->desc[1] ) ); 
			 | 
		
		
	
		
			
			| 
				549
			 | 
			
				412
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				550
			 | 
			
				413
			 | 
			
			
				
				 	/* Enqueue I/O buffer */ 
			 | 
		
		
	
		
			
			| 
				551
			 | 
			
				
			 | 
			
			
				
				-	if ( ( rc = usb_stream ( &ncm->out.ep, iobuf, 0 ) ) != 0 ) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				414
			 | 
			
			
				
				+	if ( ( rc = usb_stream ( &ncm->out, iobuf, 0 ) ) != 0 ) 
			 | 
		
		
	
		
			
			| 
				552
			 | 
			
				415
			 | 
			
			
				
				 		return rc; 
			 | 
		
		
	
		
			
			| 
				553
			 | 
			
				416
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				554
			 | 
			
				417
			 | 
			
			
				
				 	/* Increment sequence number */ 
			 | 
		
		
	
		
			
			| 
				555
			 | 
			
				
			 | 
			
			
				
				-	ncm->out.sequence++; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				418
			 | 
			
			
				
				+	ncm->sequence++; 
			 | 
		
		
	
		
			
			| 
				556
			 | 
			
				419
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				557
			 | 
			
				420
			 | 
			
			
				
				 	profile_stop ( &ncm_out_profiler ); 
			 | 
		
		
	
		
			
			| 
				558
			 | 
			
				421
			 | 
			
			
				
				 	return 0; 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -567,7 +430,7 @@ static int ncm_out_transmit ( struct ncm_device *ncm, 
			 | 
		
		
	
		
			
			| 
				567
			 | 
			
				430
			 | 
			
			
				
				  */ 
			 | 
		
		
	
		
			
			| 
				568
			 | 
			
				431
			 | 
			
			
				
				 static void ncm_out_complete ( struct usb_endpoint *ep, struct io_buffer *iobuf, 
			 | 
		
		
	
		
			
			| 
				569
			 | 
			
				432
			 | 
			
			
				
				 			       int rc ) { 
			 | 
		
		
	
		
			
			| 
				570
			 | 
			
				
			 | 
			
			
				
				-	struct ncm_device *ncm = container_of ( ep, struct ncm_device, out.ep ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				433
			 | 
			
			
				
				+	struct ncm_device *ncm = container_of ( ep, struct ncm_device, out ); 
			 | 
		
		
	
		
			
			| 
				571
			 | 
			
				434
			 | 
			
			
				
				 	struct net_device *netdev = ncm->netdev; 
			 | 
		
		
	
		
			
			| 
				572
			 | 
			
				435
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				573
			 | 
			
				436
			 | 
			
			
				
				 	/* Report TX completion */ 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -590,13 +453,13 @@ static int ncm_data_open ( struct ncm_device *ncm ) { 
			 | 
		
		
	
		
			
			| 
				590
			 | 
			
				453
			 | 
			
			
				
				 	struct ncm_set_ntb_input_size size; 
			 | 
		
		
	
		
			
			| 
				591
			 | 
			
				454
			 | 
			
			
				
				 	int rc; 
			 | 
		
		
	
		
			
			| 
				592
			 | 
			
				455
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				593
			 | 
			
				
			 | 
			
			
				
				-	/* Allocate I/O buffers */ 
			 | 
		
		
	
		
			
			| 
				594
			 | 
			
				
			 | 
			
			
				
				-	if ( ( rc = ncm_in_alloc ( ncm ) ) != 0 ) 
			 | 
		
		
	
		
			
			| 
				595
			 | 
			
				
			 | 
			
			
				
				-		goto err_alloc; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				456
			 | 
			
			
				
				+	/* Prefill I/O buffers */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				457
			 | 
			
			
				
				+	if ( ( rc = ncm_in_prefill ( ncm ) ) != 0 ) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				458
			 | 
			
			
				
				+		goto err_prefill; 
			 | 
		
		
	
		
			
			| 
				596
			 | 
			
				459
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				597
			 | 
			
				460
			 | 
			
			
				
				 	/* Set maximum input size */ 
			 | 
		
		
	
		
			
			| 
				598
			 | 
			
				461
			 | 
			
			
				
				 	memset ( &size, 0, sizeof ( size ) ); 
			 | 
		
		
	
		
			
			| 
				599
			 | 
			
				
			 | 
			
			
				
				-	size.mtu = cpu_to_le32 ( ncm->in.mtu ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				462
			 | 
			
			
				
				+	size.mtu = cpu_to_le32 ( ncm->in.len ); 
			 | 
		
		
	
		
			
			| 
				600
			 | 
			
				463
			 | 
			
			
				
				 	if ( ( rc = usb_control ( usb, NCM_SET_NTB_INPUT_SIZE, 0, ncm->comms, 
			 | 
		
		
	
		
			
			| 
				601
			 | 
			
				464
			 | 
			
			
				
				 				  &size, sizeof ( size ) ) ) != 0 ) { 
			 | 
		
		
	
		
			
			| 
				602
			 | 
			
				465
			 | 
			
			
				
				 		DBGC ( ncm, "NCM %p could not set input size to %zd: %s\n", 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -613,33 +476,38 @@ static int ncm_data_open ( struct ncm_device *ncm ) { 
			 | 
		
		
	
		
			
			| 
				613
			 | 
			
				476
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				614
			 | 
			
				477
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				615
			 | 
			
				478
			 | 
			
			
				
				 	/* Open bulk IN endpoint */ 
			 | 
		
		
	
		
			
			| 
				616
			 | 
			
				
			 | 
			
			
				
				-	if ( ( rc = usb_endpoint_open ( &ncm->in.ep ) ) != 0 ) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				479
			 | 
			
			
				
				+	if ( ( rc = usb_endpoint_open ( &ncm->in ) ) != 0 ) { 
			 | 
		
		
	
		
			
			| 
				617
			 | 
			
				480
			 | 
			
			
				
				 		DBGC ( ncm, "NCM %p could not open bulk IN: %s\n", 
			 | 
		
		
	
		
			
			| 
				618
			 | 
			
				481
			 | 
			
			
				
				 		       ncm, strerror ( rc ) ); 
			 | 
		
		
	
		
			
			| 
				619
			 | 
			
				482
			 | 
			
			
				
				 		goto err_open_in; 
			 | 
		
		
	
		
			
			| 
				620
			 | 
			
				483
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				621
			 | 
			
				484
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				622
			 | 
			
				485
			 | 
			
			
				
				 	/* Open bulk OUT endpoint */ 
			 | 
		
		
	
		
			
			| 
				623
			 | 
			
				
			 | 
			
			
				
				-	if ( ( rc = usb_endpoint_open ( &ncm->out.ep ) ) != 0 ) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				486
			 | 
			
			
				
				+	if ( ( rc = usb_endpoint_open ( &ncm->out ) ) != 0 ) { 
			 | 
		
		
	
		
			
			| 
				624
			 | 
			
				487
			 | 
			
			
				
				 		DBGC ( ncm, "NCM %p could not open bulk OUT: %s\n", 
			 | 
		
		
	
		
			
			| 
				625
			 | 
			
				488
			 | 
			
			
				
				 		       ncm, strerror ( rc ) ); 
			 | 
		
		
	
		
			
			| 
				626
			 | 
			
				489
			 | 
			
			
				
				 		goto err_open_out; 
			 | 
		
		
	
		
			
			| 
				627
			 | 
			
				490
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				628
			 | 
			
				491
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				629
			 | 
			
				
			 | 
			
			
				
				-	/* Reset transmit sequence number */ 
			 | 
		
		
	
		
			
			| 
				630
			 | 
			
				
			 | 
			
			
				
				-	ncm->out.sequence = 0; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				492
			 | 
			
			
				
				+	/* Refill bulk IN endpoint */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				493
			 | 
			
			
				
				+	if ( ( rc = usb_refill ( &ncm->in ) ) != 0 ) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				494
			 | 
			
			
				
				+		DBGC ( ncm, "NCM %p could not refill bulk IN: %s\n", 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				495
			 | 
			
			
				
				+		       ncm, strerror ( rc ) ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				496
			 | 
			
			
				
				+		goto err_refill; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				497
			 | 
			
			
				
				+	} 
			 | 
		
		
	
		
			
			| 
				631
			 | 
			
				498
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				632
			 | 
			
				499
			 | 
			
			
				
				 	return 0; 
			 | 
		
		
	
		
			
			| 
				633
			 | 
			
				500
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				634
			 | 
			
				
			 | 
			
			
				
				-	usb_endpoint_close ( &ncm->out.ep ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				501
			 | 
			
			
				
				+ err_refill: 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				502
			 | 
			
			
				
				+	usb_endpoint_close ( &ncm->out ); 
			 | 
		
		
	
		
			
			| 
				635
			 | 
			
				503
			 | 
			
			
				
				  err_open_out: 
			 | 
		
		
	
		
			
			| 
				636
			 | 
			
				
			 | 
			
			
				
				-	usb_endpoint_close ( &ncm->in.ep ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				504
			 | 
			
			
				
				+	usb_endpoint_close ( &ncm->in ); 
			 | 
		
		
	
		
			
			| 
				637
			 | 
			
				505
			 | 
			
			
				
				  err_open_in: 
			 | 
		
		
	
		
			
			| 
				638
			 | 
			
				506
			 | 
			
			
				
				 	usb_set_interface ( usb, ncm->data, 0 ); 
			 | 
		
		
	
		
			
			| 
				639
			 | 
			
				507
			 | 
			
			
				
				  err_set_interface: 
			 | 
		
		
	
		
			
			| 
				640
			 | 
			
				508
			 | 
			
			
				
				  err_set_ntb_input_size: 
			 | 
		
		
	
		
			
			| 
				641
			 | 
			
				
			 | 
			
			
				
				-	ncm_rx_free ( ncm, &ncm->in ); 
			 | 
		
		
	
		
			
			| 
				642
			 | 
			
				
			 | 
			
			
				
				- err_alloc: 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				509
			 | 
			
			
				
				+	usb_flush ( &ncm->in ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				510
			 | 
			
			
				
				+ err_prefill: 
			 | 
		
		
	
		
			
			| 
				643
			 | 
			
				511
			 | 
			
			
				
				 	return rc; 
			 | 
		
		
	
		
			
			| 
				644
			 | 
			
				512
			 | 
			
			
				
				 } 
			 | 
		
		
	
		
			
			| 
				645
			 | 
			
				513
			 | 
			
			
				
				  
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -652,14 +520,11 @@ static void ncm_data_close ( struct ncm_device *ncm ) { 
			 | 
		
		
	
		
			
			| 
				652
			 | 
			
				520
			 | 
			
			
				
				 	struct usb_device *usb = ncm->usb; 
			 | 
		
		
	
		
			
			| 
				653
			 | 
			
				521
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				654
			 | 
			
				522
			 | 
			
			
				
				 	/* Close endpoints */ 
			 | 
		
		
	
		
			
			| 
				655
			 | 
			
				
			 | 
			
			
				
				-	usb_endpoint_close ( &ncm->out.ep ); 
			 | 
		
		
	
		
			
			| 
				656
			 | 
			
				
			 | 
			
			
				
				-	usb_endpoint_close ( &ncm->in.ep ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				523
			 | 
			
			
				
				+	usb_endpoint_close ( &ncm->out ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				524
			 | 
			
			
				
				+	usb_endpoint_close ( &ncm->in ); 
			 | 
		
		
	
		
			
			| 
				657
			 | 
			
				525
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				658
			 | 
			
				526
			 | 
			
			
				
				 	/* Reset data interface */ 
			 | 
		
		
	
		
			
			| 
				659
			 | 
			
				527
			 | 
			
			
				
				 	usb_set_interface ( usb, ncm->data, 0 ); 
			 | 
		
		
	
		
			
			| 
				660
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				661
			 | 
			
				
			 | 
			
			
				
				-	/* Free I/O buffers */ 
			 | 
		
		
	
		
			
			| 
				662
			 | 
			
				
			 | 
			
			
				
				-	ncm_rx_free ( ncm, &ncm->in ); 
			 | 
		
		
	
		
			
			| 
				663
			 | 
			
				528
			 | 
			
			
				
				 } 
			 | 
		
		
	
		
			
			| 
				664
			 | 
			
				529
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				665
			 | 
			
				530
			 | 
			
			
				
				 /****************************************************************************** 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -680,30 +545,20 @@ static int ncm_open ( struct net_device *netdev ) { 
			 | 
		
		
	
		
			
			| 
				680
			 | 
			
				545
			 | 
			
			
				
				 	int rc; 
			 | 
		
		
	
		
			
			| 
				681
			 | 
			
				546
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				682
			 | 
			
				547
			 | 
			
			
				
				 	/* Reset sequence number */ 
			 | 
		
		
	
		
			
			| 
				683
			 | 
			
				
			 | 
			
			
				
				-	ncm->out.sequence = 0; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				548
			 | 
			
			
				
				+	ncm->sequence = 0; 
			 | 
		
		
	
		
			
			| 
				684
			 | 
			
				549
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				685
			 | 
			
				550
			 | 
			
			
				
				 	/* Open communications interface */ 
			 | 
		
		
	
		
			
			| 
				686
			 | 
			
				551
			 | 
			
			
				
				 	if ( ( rc = ncm_comms_open ( ncm ) ) != 0 ) 
			 | 
		
		
	
		
			
			| 
				687
			 | 
			
				552
			 | 
			
			
				
				 		goto err_comms_open; 
			 | 
		
		
	
		
			
			| 
				688
			 | 
			
				553
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				689
			 | 
			
				
			 | 
			
			
				
				-	/* Refill interrupt ring */ 
			 | 
		
		
	
		
			
			| 
				690
			 | 
			
				
			 | 
			
			
				
				-	if ( ( rc = ncm_rx_refill ( ncm, &ncm->intr ) ) != 0 ) 
			 | 
		
		
	
		
			
			| 
				691
			 | 
			
				
			 | 
			
			
				
				-		goto err_intr_refill; 
			 | 
		
		
	
		
			
			| 
				692
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				693
			 | 
			
				554
			 | 
			
			
				
				 	/* Open data interface */ 
			 | 
		
		
	
		
			
			| 
				694
			 | 
			
				555
			 | 
			
			
				
				 	if ( ( rc = ncm_data_open ( ncm ) ) != 0 ) 
			 | 
		
		
	
		
			
			| 
				695
			 | 
			
				556
			 | 
			
			
				
				 		goto err_data_open; 
			 | 
		
		
	
		
			
			| 
				696
			 | 
			
				557
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				697
			 | 
			
				
			 | 
			
			
				
				-	/* Refill bulk IN ring */ 
			 | 
		
		
	
		
			
			| 
				698
			 | 
			
				
			 | 
			
			
				
				-	if ( ( rc = ncm_rx_refill ( ncm, &ncm->in ) ) != 0 ) 
			 | 
		
		
	
		
			
			| 
				699
			 | 
			
				
			 | 
			
			
				
				-		goto err_in_refill; 
			 | 
		
		
	
		
			
			| 
				700
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				701
			 | 
			
				558
			 | 
			
			
				
				 	return 0; 
			 | 
		
		
	
		
			
			| 
				702
			 | 
			
				559
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				703
			 | 
			
				
			 | 
			
			
				
				- err_in_refill: 
			 | 
		
		
	
		
			
			| 
				704
			 | 
			
				560
			 | 
			
			
				
				 	ncm_data_close ( ncm ); 
			 | 
		
		
	
		
			
			| 
				705
			 | 
			
				561
			 | 
			
			
				
				  err_data_open: 
			 | 
		
		
	
		
			
			| 
				706
			 | 
			
				
			 | 
			
			
				
				- err_intr_refill: 
			 | 
		
		
	
		
			
			| 
				707
			 | 
			
				562
			 | 
			
			
				
				 	ncm_comms_close ( ncm ); 
			 | 
		
		
	
		
			
			| 
				708
			 | 
			
				563
			 | 
			
			
				
				  err_comms_open: 
			 | 
		
		
	
		
			
			| 
				709
			 | 
			
				564
			 | 
			
			
				
				 	return rc; 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -755,12 +610,12 @@ static void ncm_poll ( struct net_device *netdev ) { 
			 | 
		
		
	
		
			
			| 
				755
			 | 
			
				610
			 | 
			
			
				
				 	/* Poll USB bus */ 
			 | 
		
		
	
		
			
			| 
				756
			 | 
			
				611
			 | 
			
			
				
				 	usb_poll ( ncm->bus ); 
			 | 
		
		
	
		
			
			| 
				757
			 | 
			
				612
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				758
			 | 
			
				
			 | 
			
			
				
				-	/* Refill interrupt ring */ 
			 | 
		
		
	
		
			
			| 
				759
			 | 
			
				
			 | 
			
			
				
				-	if ( ( rc = ncm_rx_refill ( ncm, &ncm->intr ) ) != 0 ) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				613
			 | 
			
			
				
				+	/* Refill interrupt endpoint */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				614
			 | 
			
			
				
				+	if ( ( rc = usb_refill ( &ncm->intr ) ) != 0 ) 
			 | 
		
		
	
		
			
			| 
				760
			 | 
			
				615
			 | 
			
			
				
				 		netdev_rx_err ( netdev, NULL, rc ); 
			 | 
		
		
	
		
			
			| 
				761
			 | 
			
				616
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				762
			 | 
			
				
			 | 
			
			
				
				-	/* Refill bulk IN ring */ 
			 | 
		
		
	
		
			
			| 
				763
			 | 
			
				
			 | 
			
			
				
				-	if ( ( rc = ncm_rx_refill ( ncm, &ncm->in ) ) != 0 ) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				617
			 | 
			
			
				
				+	/* Refill bulk IN endpoint */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				618
			 | 
			
			
				
				+	if ( ( rc = usb_refill ( &ncm->in ) ) != 0 ) 
			 | 
		
		
	
		
			
			| 
				764
			 | 
			
				619
			 | 
			
			
				
				 		netdev_rx_err ( netdev, NULL, rc ); 
			 | 
		
		
	
		
			
			| 
				765
			 | 
			
				620
			 | 
			
			
				
				 } 
			 | 
		
		
	
		
			
			| 
				766
			 | 
			
				621
			 | 
			
			
				
				  
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -810,9 +665,10 @@ static int ncm_probe ( struct usb_function *func, 
			 | 
		
		
	
		
			
			| 
				810
			 | 
			
				665
			 | 
			
			
				
				 	ncm->usb = usb; 
			 | 
		
		
	
		
			
			| 
				811
			 | 
			
				666
			 | 
			
			
				
				 	ncm->bus = usb->port->hub->bus; 
			 | 
		
		
	
		
			
			| 
				812
			 | 
			
				667
			 | 
			
			
				
				 	ncm->netdev = netdev; 
			 | 
		
		
	
		
			
			| 
				813
			 | 
			
				
			 | 
			
			
				
				-	usb_endpoint_init ( &ncm->intr.ep, usb, &ncm_intr_operations ); 
			 | 
		
		
	
		
			
			| 
				814
			 | 
			
				
			 | 
			
			
				
				-	usb_endpoint_init ( &ncm->in.ep, usb, &ncm_in_operations ); 
			 | 
		
		
	
		
			
			| 
				815
			 | 
			
				
			 | 
			
			
				
				-	usb_endpoint_init ( &ncm->out.ep, usb, &ncm_out_operations ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				668
			 | 
			
			
				
				+	usb_endpoint_init ( &ncm->intr, usb, &ncm_intr_operations ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				669
			 | 
			
			
				
				+	usb_endpoint_init ( &ncm->in, usb, &ncm_in_operations ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				670
			 | 
			
			
				
				+	usb_endpoint_init ( &ncm->out, usb, &ncm_out_operations ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				671
			 | 
			
			
				
				+	usb_refill_init ( &ncm->intr, 0, NCM_INTR_COUNT ); 
			 | 
		
		
	
		
			
			| 
				816
			 | 
			
				672
			 | 
			
			
				
				 	DBGC ( ncm, "NCM %p on %s\n", ncm, func->name ); 
			 | 
		
		
	
		
			
			| 
				817
			 | 
			
				673
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				818
			 | 
			
				674
			 | 
			
			
				
				 	/* Identify interfaces */ 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -843,7 +699,7 @@ static int ncm_probe ( struct usb_function *func, 
			 | 
		
		
	
		
			
			| 
				843
			 | 
			
				699
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				844
			 | 
			
				700
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				845
			 | 
			
				701
			 | 
			
			
				
				 	/* Describe interrupt endpoint */ 
			 | 
		
		
	
		
			
			| 
				846
			 | 
			
				
			 | 
			
			
				
				-	if ( ( rc = usb_endpoint_described ( &ncm->intr.ep, config, comms, 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				702
			 | 
			
			
				
				+	if ( ( rc = usb_endpoint_described ( &ncm->intr, config, comms, 
			 | 
		
		
	
		
			
			| 
				847
			 | 
			
				703
			 | 
			
			
				
				 					     USB_INTERRUPT, 0 ) ) != 0 ) { 
			 | 
		
		
	
		
			
			| 
				848
			 | 
			
				704
			 | 
			
			
				
				 		DBGC ( ncm, "NCM %p could not describe interrupt endpoint: " 
			 | 
		
		
	
		
			
			| 
				849
			 | 
			
				705
			 | 
			
			
				
				 		       "%s\n", ncm, strerror ( rc ) ); 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -851,7 +707,7 @@ static int ncm_probe ( struct usb_function *func, 
			 | 
		
		
	
		
			
			| 
				851
			 | 
			
				707
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				852
			 | 
			
				708
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				853
			 | 
			
				709
			 | 
			
			
				
				 	/* Describe bulk IN endpoint */ 
			 | 
		
		
	
		
			
			| 
				854
			 | 
			
				
			 | 
			
			
				
				-	if ( ( rc = usb_endpoint_described ( &ncm->in.ep, config, data, 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				710
			 | 
			
			
				
				+	if ( ( rc = usb_endpoint_described ( &ncm->in, config, data, 
			 | 
		
		
	
		
			
			| 
				855
			 | 
			
				711
			 | 
			
			
				
				 					     USB_BULK_IN, 0 ) ) != 0 ) { 
			 | 
		
		
	
		
			
			| 
				856
			 | 
			
				712
			 | 
			
			
				
				 		DBGC ( ncm, "NCM %p could not describe bulk IN endpoint: " 
			 | 
		
		
	
		
			
			| 
				857
			 | 
			
				713
			 | 
			
			
				
				 		       "%s\n", ncm, strerror ( rc ) ); 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -859,7 +715,7 @@ static int ncm_probe ( struct usb_function *func, 
			 | 
		
		
	
		
			
			| 
				859
			 | 
			
				715
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				860
			 | 
			
				716
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				861
			 | 
			
				717
			 | 
			
			
				
				 	/* Describe bulk OUT endpoint */ 
			 | 
		
		
	
		
			
			| 
				862
			 | 
			
				
			 | 
			
			
				
				-	if ( ( rc = usb_endpoint_described ( &ncm->out.ep, config, data, 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				718
			 | 
			
			
				
				+	if ( ( rc = usb_endpoint_described ( &ncm->out, config, data, 
			 | 
		
		
	
		
			
			| 
				863
			 | 
			
				719
			 | 
			
			
				
				 					     USB_BULK_OUT, 0 ) ) != 0 ) { 
			 | 
		
		
	
		
			
			| 
				864
			 | 
			
				720
			 | 
			
			
				
				 		DBGC ( ncm, "NCM %p could not describe bulk OUT endpoint: " 
			 | 
		
		
	
		
			
			| 
				865
			 | 
			
				721
			 | 
			
			
				
				 		       "%s\n", ncm, strerror ( rc ) ); 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -894,12 +750,12 @@ static int ncm_probe ( struct usb_function *func, 
			 | 
		
		
	
		
			
			| 
				894
			 | 
			
				750
			 | 
			
			
				
				 	DBGC2 ( ncm, "NCM %p maximum IN size is %zd bytes\n", ncm, ncm->mtu ); 
			 | 
		
		
	
		
			
			| 
				895
			 | 
			
				751
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				896
			 | 
			
				752
			 | 
			
			
				
				 	/* Calculate transmit padding */ 
			 | 
		
		
	
		
			
			| 
				897
			 | 
			
				
			 | 
			
			
				
				-	ncm->out.padding = ( ( le16_to_cpu ( params.out.remainder ) - 
			 | 
		
		
	
		
			
			| 
				898
			 | 
			
				
			 | 
			
			
				
				-			       sizeof ( struct ncm_ntb_header ) - ETH_HLEN ) & 
			 | 
		
		
	
		
			
			| 
				899
			 | 
			
				
			 | 
			
			
				
				-			     ( le16_to_cpu ( params.out.divisor ) - 1 ) ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				753
			 | 
			
			
				
				+	ncm->padding = ( ( le16_to_cpu ( params.out.remainder ) - 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				754
			 | 
			
			
				
				+			   sizeof ( struct ncm_ntb_header ) - ETH_HLEN ) & 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				755
			 | 
			
			
				
				+			 ( le16_to_cpu ( params.out.divisor ) - 1 ) ); 
			 | 
		
		
	
		
			
			| 
				900
			 | 
			
				756
			 | 
			
			
				
				 	DBGC2 ( ncm, "NCM %p using %zd-byte transmit padding\n", 
			 | 
		
		
	
		
			
			| 
				901
			 | 
			
				
			 | 
			
			
				
				-		ncm, ncm->out.padding ); 
			 | 
		
		
	
		
			
			| 
				902
			 | 
			
				
			 | 
			
			
				
				-	assert ( ( ( sizeof ( struct ncm_ntb_header ) + ncm->out.padding + 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				757
			 | 
			
			
				
				+		ncm, ncm->padding ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				758
			 | 
			
			
				
				+	assert ( ( ( sizeof ( struct ncm_ntb_header ) + ncm->padding + 
			 | 
		
		
	
		
			
			| 
				903
			 | 
			
				759
			 | 
			
			
				
				 		     ETH_HLEN ) % le16_to_cpu ( params.out.divisor ) ) == 
			 | 
		
		
	
		
			
			| 
				904
			 | 
			
				760
			 | 
			
			
				
				 		 le16_to_cpu ( params.out.remainder ) ); 
			 | 
		
		
	
		
			
			| 
				905
			 | 
			
				761
			 | 
			
			
				
				  
			 |