aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Brandeburg <jesse.brandeburg@intel.com>2009-04-27 18:35:52 -0400
committerDavid S. Miller <davem@davemloft.net>2009-04-28 04:53:14 -0400
commit8dc92f7e2ecfd93f5c57da78594a7a5482e2c15e (patch)
tree10ebbfa0dc4f0b175c95cf47f2ba013aa532676e
parent182ff8dfdb63e66ca81e4d3a4c746f8d578e5687 (diff)
sctp: add feature bit for SCTP offload in hardware
this is the sctp code to enable hardware crc32c offload for adapters that support it. Originally by: Vlad Yasevich <vladislav.yasevich@hp.com> modified by Jesse Brandeburg <jesse.brandeburg@intel.com> Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com> Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/netdevice.h2
-rw-r--r--net/sctp/output.c17
2 files changed, 16 insertions, 3 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index fe20d171acf1..f8c3619d551f 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -670,7 +670,9 @@ struct net_device
670#define NETIF_F_GRO 16384 /* Generic receive offload */ 670#define NETIF_F_GRO 16384 /* Generic receive offload */
671#define NETIF_F_LRO 32768 /* large receive offload */ 671#define NETIF_F_LRO 32768 /* large receive offload */
672 672
673/* the GSO_MASK reserves bits 16 through 23 */
673#define NETIF_F_FCOE_CRC (1 << 24) /* FCoE CRC32 */ 674#define NETIF_F_FCOE_CRC (1 << 24) /* FCoE CRC32 */
675#define NETIF_F_SCTP_CSUM (1 << 25) /* SCTP checksum offload */
674 676
675 /* Segmentation offload features */ 677 /* Segmentation offload features */
676#define NETIF_F_GSO_SHIFT 16 678#define NETIF_F_GSO_SHIFT 16
diff --git a/net/sctp/output.c b/net/sctp/output.c
index 7d08f522ec84..f0c91df59d4e 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -412,6 +412,7 @@ int sctp_packet_transmit(struct sctp_packet *packet)
412 412
413 /* Build the SCTP header. */ 413 /* Build the SCTP header. */
414 sh = (struct sctphdr *)skb_push(nskb, sizeof(struct sctphdr)); 414 sh = (struct sctphdr *)skb_push(nskb, sizeof(struct sctphdr));
415 skb_reset_transport_header(nskb);
415 sh->source = htons(packet->source_port); 416 sh->source = htons(packet->source_port);
416 sh->dest = htons(packet->destination_port); 417 sh->dest = htons(packet->destination_port);
417 418
@@ -527,15 +528,25 @@ int sctp_packet_transmit(struct sctp_packet *packet)
527 * Note: Adler-32 is no longer applicable, as has been replaced 528 * Note: Adler-32 is no longer applicable, as has been replaced
528 * by CRC32-C as described in <draft-ietf-tsvwg-sctpcsum-02.txt>. 529 * by CRC32-C as described in <draft-ietf-tsvwg-sctpcsum-02.txt>.
529 */ 530 */
530 if (!sctp_checksum_disable && !(dst->dev->features & NETIF_F_NO_CSUM)) { 531 if (!sctp_checksum_disable &&
532 !(dst->dev->features & (NETIF_F_NO_CSUM | NETIF_F_SCTP_CSUM))) {
531 __u32 crc32 = sctp_start_cksum((__u8 *)sh, cksum_buf_len); 533 __u32 crc32 = sctp_start_cksum((__u8 *)sh, cksum_buf_len);
532 534
533 /* 3) Put the resultant value into the checksum field in the 535 /* 3) Put the resultant value into the checksum field in the
534 * common header, and leave the rest of the bits unchanged. 536 * common header, and leave the rest of the bits unchanged.
535 */ 537 */
536 sh->checksum = sctp_end_cksum(crc32); 538 sh->checksum = sctp_end_cksum(crc32);
537 } else 539 } else {
538 nskb->ip_summed = CHECKSUM_UNNECESSARY; 540 if (dst->dev->features & NETIF_F_SCTP_CSUM) {
541 /* no need to seed psuedo checksum for SCTP */
542 nskb->ip_summed = CHECKSUM_PARTIAL;
543 nskb->csum_start = (skb_transport_header(nskb) -
544 nskb->head);
545 nskb->csum_offset = offsetof(struct sctphdr, checksum);
546 } else {
547 nskb->ip_summed = CHECKSUM_UNNECESSARY;
548 }
549 }
539 550
540 /* IP layer ECN support 551 /* IP layer ECN support
541 * From RFC 2481 552 * From RFC 2481