It can be any one of the three. The name means, literally, son of Gustaf. At the beginning of civilization, there weren't a tremendous amount of people and people generally had one name they were known by. Surnames came about as a way to differentiate individuals within a tribe, or the place they were from, or by what they did, and often, by family.
The Swedish variation of 'son' can be, but is not always, 'sen'. And, the use of 'sen' is not strictly limited to Sweden.
In some cultures, the surnames are gender-specific. It is common with names of Slavic origin for the surname of the female to be that of the family with an 'a' at the end. In the Pavlov family, males would be Pavlov and females Pavlova. In Iceland, it is very common to see females with a surname ending in 'dottir' - or 'daughter of'.