Skip to content

Commit c76acec

Browse files
dajtStefan Richter
authored andcommitted
firewire: add IPv4 support
Implement IPv4 over IEEE 1394 as per RFC 2734 for the newer firewire stack. This feature has only been present in the older ieee1394 stack via the eth1394 driver. Still to do: - fix ipv4_priv and ipv4_node lifetime logic - fix determination of speeds and max payloads - fix bus reset handling - fix unaligned memory accesses - fix coding style - further testing/ improvement of fragment reassembly - perhaps multicast support Signed-off-by: Jay Fenlason <fenlason@redhat.com> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> (rebased, copyright note, changelog)
1 parent 1e626fd commit c76acec

6 files changed

Lines changed: 1926 additions & 87 deletions

File tree

‎drivers/firewire/Makefile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ firewire-core-y += core-card.o core-cdev.o core-device.o \
66
core-iso.o core-topology.o core-transaction.o
77
firewire-ohci-y += ohci.o
88
firewire-sbp2-y += sbp2.o
9+
firewire-ipv4-y += fw-ipv4.o
910

1011
obj-$(CONFIG_FIREWIRE) += firewire-core.o
1112
obj-$(CONFIG_FIREWIRE_OHCI) += firewire-ohci.o
1213
obj-$(CONFIG_FIREWIRE_SBP2) += firewire-sbp2.o
14+
obj-$(CONFIG_FIREWIRE_IPV4) += firewire-ipv4.o

‎drivers/firewire/core-card.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ int fw_core_add_descriptor(struct fw_descriptor *desc)
176176

177177
return 0;
178178
}
179+
EXPORT_SYMBOL(fw_core_add_descriptor);
179180

180181
void fw_core_remove_descriptor(struct fw_descriptor *desc)
181182
{
@@ -189,6 +190,7 @@ void fw_core_remove_descriptor(struct fw_descriptor *desc)
189190

190191
mutex_unlock(&card_mutex);
191192
}
193+
EXPORT_SYMBOL(fw_core_remove_descriptor);
192194

193195
static void allocate_broadcast_channel(struct fw_card *card, int generation)
194196
{
@@ -427,6 +429,8 @@ void fw_card_initialize(struct fw_card *card,
427429
card->local_node = NULL;
428430

429431
INIT_DELAYED_WORK(&card->work, fw_card_bm_work);
432+
card->netdev = NULL;
433+
INIT_LIST_HEAD(&card->ipv4_nodes);
430434
}
431435
EXPORT_SYMBOL(fw_card_initialize);
432436

‎drivers/firewire/core-iso.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card,
8080

8181
return -ENOMEM;
8282
}
83+
EXPORT_SYMBOL(fw_iso_buffer_init);
8384

8485
int fw_iso_buffer_map(struct fw_iso_buffer *buffer, struct vm_area_struct *vma)
8586
{
@@ -114,6 +115,7 @@ void fw_iso_buffer_destroy(struct fw_iso_buffer *buffer,
114115
kfree(buffer->pages);
115116
buffer->pages = NULL;
116117
}
118+
EXPORT_SYMBOL(fw_iso_buffer_destroy);
117119

118120
struct fw_iso_context *fw_iso_context_create(struct fw_card *card,
119121
int type, int channel, int speed, size_t header_size,
@@ -136,19 +138,22 @@ struct fw_iso_context *fw_iso_context_create(struct fw_card *card,
136138

137139
return ctx;
138140
}
141+
EXPORT_SYMBOL(fw_iso_context_create);
139142

140143
void fw_iso_context_destroy(struct fw_iso_context *ctx)
141144
{
142145
struct fw_card *card = ctx->card;
143146

144147
card->driver->free_iso_context(ctx);
145148
}
149+
EXPORT_SYMBOL(fw_iso_context_destroy);
146150

147151
int fw_iso_context_start(struct fw_iso_context *ctx,
148152
int cycle, int sync, int tags)
149153
{
150154
return ctx->card->driver->start_iso(ctx, cycle, sync, tags);
151155
}
156+
EXPORT_SYMBOL(fw_iso_context_start);
152157

153158
int fw_iso_context_queue(struct fw_iso_context *ctx,
154159
struct fw_iso_packet *packet,
@@ -159,11 +164,13 @@ int fw_iso_context_queue(struct fw_iso_context *ctx,
159164

160165
return card->driver->queue_iso(ctx, packet, buffer, payload);
161166
}
167+
EXPORT_SYMBOL(fw_iso_context_queue);
162168

163169
int fw_iso_context_stop(struct fw_iso_context *ctx)
164170
{
165171
return ctx->card->driver->stop_iso(ctx);
166172
}
173+
EXPORT_SYMBOL(fw_iso_context_stop);
167174

168175
/*
169176
* Isochronous bus resource management (channels, bandwidth), client side

‎drivers/firewire/core.h‎

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef _FIREWIRE_CORE_H
22
#define _FIREWIRE_CORE_H
33

4-
#include <linux/dma-mapping.h>
54
#include <linux/fs.h>
65
#include <linux/list.h>
76
#include <linux/idr.h>
@@ -97,17 +96,6 @@ int fw_core_initiate_bus_reset(struct fw_card *card, int short_reset);
9796
int fw_compute_block_crc(u32 *block);
9897
void fw_schedule_bm_work(struct fw_card *card, unsigned long delay);
9998

100-
struct fw_descriptor {
101-
struct list_head link;
102-
size_t length;
103-
u32 immediate;
104-
u32 key;
105-
const u32 *data;
106-
};
107-
108-
int fw_core_add_descriptor(struct fw_descriptor *desc);
109-
void fw_core_remove_descriptor(struct fw_descriptor *desc);
110-
11199

112100
/* -cdev */
113101

@@ -130,77 +118,7 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event);
130118

131119
/* -iso */
132120

133-
/*
134-
* The iso packet format allows for an immediate header/payload part
135-
* stored in 'header' immediately after the packet info plus an
136-
* indirect payload part that is pointer to by the 'payload' field.
137-
* Applications can use one or the other or both to implement simple
138-
* low-bandwidth streaming (e.g. audio) or more advanced
139-
* scatter-gather streaming (e.g. assembling video frame automatically).
140-
*/
141-
struct fw_iso_packet {
142-
u16 payload_length; /* Length of indirect payload. */
143-
u32 interrupt:1; /* Generate interrupt on this packet */
144-
u32 skip:1; /* Set to not send packet at all. */
145-
u32 tag:2;
146-
u32 sy:4;
147-
u32 header_length:8; /* Length of immediate header. */
148-
u32 header[0];
149-
};
150-
151-
#define FW_ISO_CONTEXT_TRANSMIT 0
152-
#define FW_ISO_CONTEXT_RECEIVE 1
153-
154-
#define FW_ISO_CONTEXT_MATCH_TAG0 1
155-
#define FW_ISO_CONTEXT_MATCH_TAG1 2
156-
#define FW_ISO_CONTEXT_MATCH_TAG2 4
157-
#define FW_ISO_CONTEXT_MATCH_TAG3 8
158-
#define FW_ISO_CONTEXT_MATCH_ALL_TAGS 15
159-
160-
/*
161-
* An iso buffer is just a set of pages mapped for DMA in the
162-
* specified direction. Since the pages are to be used for DMA, they
163-
* are not mapped into the kernel virtual address space. We store the
164-
* DMA address in the page private. The helper function
165-
* fw_iso_buffer_map() will map the pages into a given vma.
166-
*/
167-
struct fw_iso_buffer {
168-
enum dma_data_direction direction;
169-
struct page **pages;
170-
int page_count;
171-
};
172-
173-
typedef void (*fw_iso_callback_t)(struct fw_iso_context *context,
174-
u32 cycle, size_t header_length,
175-
void *header, void *data);
176-
177-
struct fw_iso_context {
178-
struct fw_card *card;
179-
int type;
180-
int channel;
181-
int speed;
182-
size_t header_size;
183-
fw_iso_callback_t callback;
184-
void *callback_data;
185-
};
186-
187-
int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card,
188-
int page_count, enum dma_data_direction direction);
189121
int fw_iso_buffer_map(struct fw_iso_buffer *buffer, struct vm_area_struct *vma);
190-
void fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, struct fw_card *card);
191-
192-
struct fw_iso_context *fw_iso_context_create(struct fw_card *card,
193-
int type, int channel, int speed, size_t header_size,
194-
fw_iso_callback_t callback, void *callback_data);
195-
int fw_iso_context_queue(struct fw_iso_context *ctx,
196-
struct fw_iso_packet *packet,
197-
struct fw_iso_buffer *buffer,
198-
unsigned long payload);
199-
int fw_iso_context_start(struct fw_iso_context *ctx,
200-
int cycle, int sync, int tags);
201-
int fw_iso_context_stop(struct fw_iso_context *ctx);
202-
void fw_iso_context_destroy(struct fw_iso_context *ctx);
203-
204122
void fw_iso_resource_manage(struct fw_card *card, int generation,
205123
u64 channels_mask, int *channel, int *bandwidth, bool allocate);
206124

@@ -285,9 +203,4 @@ void fw_flush_transactions(struct fw_card *card);
285203
void fw_send_phy_config(struct fw_card *card,
286204
int node_id, int generation, int gap_count);
287205

288-
static inline int fw_stream_packet_destination_id(int tag, int channel, int sy)
289-
{
290-
return tag << 14 | channel << 8 | sy;
291-
}
292-
293206
#endif /* _FIREWIRE_CORE_H */

0 commit comments

Comments
 (0)