@@ -637,15 +637,13 @@ static int af_alg_alloc_tsgl(struct sock *sk)
637637/**
638638 * af_alg_count_tsgl - Count number of TX SG entries
639639 *
640- * The counting starts from the beginning of the SGL to @bytes. If
641- * an @offset is provided, the counting of the SG entries starts at the @offset.
640+ * The counting starts from the beginning of the SGL to @bytes.
642641 *
643642 * @sk: socket of connection to user space
644643 * @bytes: Count the number of SG entries holding given number of bytes.
645- * @offset: Start the counting of SG entries from the given offset.
646644 * Return: Number of TX SG entries found given the constraints
647645 */
648- unsigned int af_alg_count_tsgl (struct sock * sk , size_t bytes , size_t offset )
646+ unsigned int af_alg_count_tsgl (struct sock * sk , size_t bytes )
649647{
650648 const struct alg_sock * ask = alg_sk (sk );
651649 const struct af_alg_ctx * ctx = ask -> private ;
@@ -660,25 +658,11 @@ unsigned int af_alg_count_tsgl(struct sock *sk, size_t bytes, size_t offset)
660658 const struct scatterlist * sg = sgl -> sg ;
661659
662660 for (i = 0 ; i < sgl -> cur ; i ++ ) {
663- size_t bytes_count ;
664-
665- /* Skip offset */
666- if (offset >= sg [i ].length ) {
667- offset -= sg [i ].length ;
668- bytes -= sg [i ].length ;
669- continue ;
670- }
671-
672- bytes_count = sg [i ].length - offset ;
673-
674- offset = 0 ;
675661 sgl_count ++ ;
676-
677- /* If we have seen requested number of bytes, stop */
678- if (bytes_count >= bytes )
662+ if (sg [i ].length >= bytes )
679663 return sgl_count ;
680664
681- bytes -= bytes_count ;
665+ bytes -= sg [ i ]. length ;
682666 }
683667 }
684668
@@ -690,19 +674,14 @@ EXPORT_SYMBOL_GPL(af_alg_count_tsgl);
690674 * af_alg_pull_tsgl - Release the specified buffers from TX SGL
691675 *
692676 * If @dst is non-null, reassign the pages to @dst. The caller must release
693- * the pages. If @dst_offset is given only reassign the pages to @dst starting
694- * at the @dst_offset (byte). The caller must ensure that @dst is large
695- * enough (e.g. by using af_alg_count_tsgl with the same offset).
677+ * the pages.
696678 *
697679 * @sk: socket of connection to user space
698680 * @used: Number of bytes to pull from TX SGL
699681 * @dst: If non-NULL, buffer is reassigned to dst SGL instead of releasing. The
700682 * caller must release the buffers in dst.
701- * @dst_offset: Reassign the TX SGL from given offset. All buffers before
702- * reaching the offset is released.
703683 */
704- void af_alg_pull_tsgl (struct sock * sk , size_t used , struct scatterlist * dst ,
705- size_t dst_offset )
684+ void af_alg_pull_tsgl (struct sock * sk , size_t used , struct scatterlist * dst )
706685{
707686 struct alg_sock * ask = alg_sk (sk );
708687 struct af_alg_ctx * ctx = ask -> private ;
@@ -726,19 +705,11 @@ void af_alg_pull_tsgl(struct sock *sk, size_t used, struct scatterlist *dst,
726705 * Assumption: caller created af_alg_count_tsgl(len)
727706 * SG entries in dst.
728707 */
729- if (dst ) {
730- if (dst_offset >= plen ) {
731- /* discard page before offset */
732- dst_offset -= plen ;
733- } else {
734- /* reassign page to dst after offset */
735- get_page (page );
736- sg_set_page (dst + j , page ,
737- plen - dst_offset ,
738- sg [i ].offset + dst_offset );
739- dst_offset = 0 ;
740- j ++ ;
741- }
708+ if (dst && plen ) {
709+ /* reassign page to dst */
710+ get_page (page );
711+ sg_set_page (dst + j , page , plen , sg [i ].offset );
712+ j ++ ;
742713 }
743714
744715 sg [i ].length -= plen ;
0 commit comments